Skip to content

Replace pytz with stdlib zoneinfo#2077

Merged
rytilahti merged 3 commits into
masterfrom
remove-pytz-dependency
Jun 27, 2026
Merged

Replace pytz with stdlib zoneinfo#2077
rytilahti merged 3 commits into
masterfrom
remove-pytz-dependency

Conversation

@syssi

@syssi syssi commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Closes #1825

Summary

  • Remove pytz dependency from pyproject.toml
  • Replace pytz.timezone() with ZoneInfo() from stdlib zoneinfo module (Python 3.9+, now project minimum)
  • Replace timezone.localize(dt) (pytz-specific) with dt.replace(tzinfo=timezone) (standard)
  • Update BaseTzInfo type annotation to ZoneInfo

Tests

New tests in TestVacuum:

  • test_timer_with_timezone — Timer parses cron and returns a timezone-aware next_schedule
  • test_timer_disabled — Timer respects off state
  • test_timer_ts — Timer creation timestamp is parsed from unix ID
  • test_timer_ts_non_numeric_id — Non-numeric timer IDs (e.g. valetudo) return None for ts
  • test_timer_listvacuum.timer() builds Timer objects via ZoneInfo
  • test_configure_wifi_with_timezone — UTC offset is 0.0 for UTC
  • test_configure_wifi_with_offset_timezone — UTC offset is 8.0 for Asia/Shanghai

All 47 tests pass.

syssi added 3 commits June 27, 2026 17:02
zoneinfo is available since Python 3.9 (now minimum), so pytz is no longer needed.
Replace pytz.timezone() with ZoneInfo() and timezone.localize() with .replace(tzinfo=).
Add tests for Timer timezone handling and configure_wifi gmt_offset calculation.
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.49%. Comparing base (bacf59f) to head (b6710e8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2077      +/-   ##
==========================================
+ Coverage   83.29%   83.49%   +0.19%     
==========================================
  Files         199      199              
  Lines       19475    19519      +44     
  Branches     1058     1058              
==========================================
+ Hits        16222    16297      +75     
+ Misses       3071     3036      -35     
- Partials      182      186       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@syssi syssi requested a review from rytilahti June 27, 2026 15:14
@rytilahti rytilahti merged commit 8d63876 into master Jun 27, 2026
14 checks passed
@rytilahti rytilahti deleted the remove-pytz-dependency branch June 27, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider removing pytz dependency

2 participants