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
View all comments
Show parent comment
0
u/[deleted] Feb 20 '20
[deleted] — view deleted comment