Skip to content

refactor(backend): replace pytz with stdlib zoneinfo/datetime.UTC#1147

Merged
c0rydoras merged 4 commits intomainfrom
copilot/refactor-pytz-to-stdlib-datetime
Apr 2, 2026
Merged

refactor(backend): replace pytz with stdlib zoneinfo/datetime.UTC#1147
c0rydoras merged 4 commits intomainfrom
copilot/refactor-pytz-to-stdlib-datetime

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

pytz was a direct runtime dependency used in exactly one place: a 2017 data migration. Replace it with stdlib equivalents available since Python 3.9/3.11, eliminating the third-party dependency entirely.

Changes

  • migrations/0002_auto_20170912_1346.py — swap pytz primitives for stdlib:
    • pytz.timezone(name)ZoneInfo(name) (zoneinfo, stdlib since 3.9)
    • pytz.utcUTC (datetime.UTC, stdlib since 3.11; project targets 3.12)
  • pyproject.toml — remove pytz dependency
  • poetry.lock — regenerated
# before
from pytz import timezone, utc
current_tz = timezone(settings.TIME_ZONE)
block.from_datetime = block.from_datetime.astimezone(current_tz).replace(tzinfo=utc)

# after
from datetime import UTC
from zoneinfo import ZoneInfo
current_tz = ZoneInfo(settings.TIME_ZONE)
block.from_datetime = block.from_datetime.astimezone(current_tz).replace(tzinfo=UTC)

@hairmare hairmare changed the title Replace pytz with stdlib zoneinfo/datetime.UTC refactor: Replace pytz with stdlib zoneinfo/datetime.UTC Apr 1, 2026
@c0rydoras c0rydoras changed the title refactor: Replace pytz with stdlib zoneinfo/datetime.UTC refactor(backend): replace pytz with stdlib zoneinfo/datetime.UTC Apr 1, 2026
@c0rydoras c0rydoras added refactor This issue or pull request discusses refactoring backend This issue or pull request is backend related dependencies Pull requests that update a dependency file labels Apr 1, 2026
@hairmare hairmare marked this pull request as ready for review April 1, 2026 16:27
@hairmare hairmare requested a review from a team as a code owner April 1, 2026 16:27
@c0rydoras
Copy link
Copy Markdown
Collaborator

CI failing due to #1105

Copy link
Copy Markdown
Collaborator

@c0rydoras c0rydoras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one less dependency to worry about 🚀

Copy link
Copy Markdown
Member

@winged winged left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 🚀

@c0rydoras c0rydoras merged commit 7375d59 into main Apr 2, 2026
7 checks passed
@c0rydoras c0rydoras deleted the copilot/refactor-pytz-to-stdlib-datetime branch April 2, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend This issue or pull request is backend related dependencies Pull requests that update a dependency file refactor This issue or pull request discusses refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants