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.
-
So, I was trying to write a
Protocol
that captures the essence ofdatetime
-like data types. (In particulardatetime.datetime
,numpy.datetime64
andpandas.Timestamp
). The problem is how to annotate the__add__
and__sub__
-methods. Eachdatetime
-type has a pairedtimedelta
type (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 passespyright
with warnings (TD
is unbound), butmypy
hates it.Beta Was this translation helpful? Give feedback.
All reactions