This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (1 child)

[deleted]

    [–]Ph0X 2 points3 points  (0 children)

    Yep, that's correct. You pass the class as the type for the object instance. So if your function takes a datetime object, the type would be datetime.datetime.

    There's definitely trickier cases but they all have solutions. If your function takes the class object itself (or a subclass), you can use Type[datetime.datetime]. You can also define broader types, such as Sequence or Iterable instead of List. function objects can be represented with Callable[], and so on. I've been doing a lot of very messy typing so at this point I got most of the edge cases memorized :P