DateTime - Protocol possible with current typing features?
#1493
Replies: 1 comment 6 replies
-
|
I'm not sure this makes a whole lot of sense, since this would allow mixing incompatible If you want to make this work despite this, then you have to use If I change |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
So, I was trying to write a
Protocolthat captures the essence ofdatetime-like data types. (In particulardatetime.datetime,numpy.datetime64andpandas.Timestamp). The problem is how to annotate the__add__and__sub__-methods. Eachdatetime-type has a pairedtimedeltatype (datetime.timedelta,numpy.timedelta64,pandas.Timedelta), and it's unclear to me how to deal with that. This is what I have so far, it passespyrightwith warnings (TDis unbound), butmypyhates it.Beta Was this translation helpful? Give feedback.
All reactions