This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
Consistently use TZ-aware/unaware datetime
values
#851
Labels
datetime
values
#851
Python
datetime
objects can be TZ-aware or unaware. In the service code, we are inconsistent in our usage of one or another (mostly using TZ-unaware).If we only perform local calculations with objects of the same awareness, no problems can occur. But if they differ and we compare them, they may fail in (inconsistent) ways:
==
comparisons silently fail, and evaluateFalse
when comparing two semantically-equaldatetime
objects, but where just one is TZ-aware<
, &c) throw an exceptionTZ-awareness appears to not be statically-checkable out of the box. See python/mypy#10067.
We seem to only use TZ-aware code in some parts of the proxy (which caused pain in testing for #839). The quick fix is just to update our usage there. Trying to change the existing (predominantly unaware) code to TZ-aware will likely have a long tail of bugs. A longer-term and safer fix could be to use our own (more statically-constrained)
datetime
wrappers or subclasses, and move everything to those, to prevent mismatches in the future.AB#39994539
The text was updated successfully, but these errors were encountered: