Replace pytz with zoneinfo#329
Conversation
- For python 3.8, add backports.zoneinfo and import accordingly. Python 3.8 is still supported for Django 4.2. - Make the localize argument to `stats_to_list` a boolean, since we no longer use a pytz-centric API. - pytz uses normalize() to deal with DST folding when changing from or to a DST timezone, however, zoneinfo handles this differently and doesn't require normalization. - While in here, add Django 5.1 to the test matrix
pcraciunoiu
left a comment
There was a problem hiding this comment.
Looks good to me!
-
Before I merge and release, could you confirm that you tested manually as well?
-
I didn't yet check, is there a unit test covering any of this timezone logic? If not, adding one would be great.
Thanks for contributing.
|
I ran the tests, thinking there would be a test for it, but if you're usure, I'll run coverage and add a test if needed. |
So lines 41-62 are covered. |
Would you mind testing it from your branch before I make a release? That would give some assurance and avoid having to release a hotfix if you do find something. |
Add a test that verifies that timestamps are localized to settings.TIME_ZONE and hours adjusted accordingly.
|
So coverage was a bit misleading, there's not an actual test that looks at the timezone. One thing I noted was that The default is |
|
@msopacua great stuff. I wonder how hard it would be to fix the override settings for tests, it's unfortunate that doesn't work. May be the repo needs to be updated to import the django settings. But that seems out of scope for this PR (and I would prefer it to be separate anyways). Looking at this more closely, the changes are purely for the stats code, so I'd be OK to make a release. I'd still like to wait until you run a manual test on a project to do so, that way you can test the code close to release time rather than it being released for a while. That said, the code changes look good. |
|
Thanks! Released as v4.1.1 |

stats_to_lista boolean, since we no longer use a pytz-centric API.closes #313