You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
datetime.datetime objects created with timezone information cannot be compared to datetime objects without timezone information. This error comes up
TypeError: can't compare offset-naive and offset-aware datetimes
I believe it is possible for the type system to handle distinguishing between these two objects.
I have a proof of concept at my Company that looks something like this. The idea is to distinguish between these two object types and forbid their corresponding comparisons.
It would be great if we could somehow distinguish between tz-aware and naive datetimes using type checking and this is a clever idea. And yes, ideally this should be solved in the datetime library (like the nonsensical inheritance of datetime from date), but I can't see that happening realistically.
That said, I don't think this solution would really work for typeshed. Sticking close to the implementation is fairly important to use for various reasons, and introducing "fake" classes like this can easily add unforeseen problems.
Another approach I tried (and which I should look at again) is making datetime generic over tzinfo, see python/typeshed#11844.
datetime.datetime objects created with timezone information cannot be compared to datetime objects without timezone information. This error comes up
I believe it is possible for the type system to handle distinguishing between these two objects.
I have a proof of concept at my Company that looks something like this. The idea is to distinguish between these two object types and forbid their corresponding comparisons.
I have some questions before I'm certain this could be possible for everyone
The text was updated successfully, but these errors were encountered: