Skip to content

fix: use timezone.utc instead of datetime.UTC for Python 3.10 compat#11

Merged
jensens merged 1 commit into
mainfrom
fix/py310-utc-import
Jun 23, 2026
Merged

fix: use timezone.utc instead of datetime.UTC for Python 3.10 compat#11
jensens merged 1 commit into
mainfrom
fix/py310-utc-import

Conversation

@jensens

@jensens jensens commented Jun 23, 2026

Copy link
Copy Markdown
Member

Problem

CI is red on main: test collection fails on Python 3.10 because two test files import datetime.UTC, which was only added in Python 3.11. The package declares requires-python = ">=3.10" and ships the 3.10 classifier, so this is a genuine compatibility gap.

ImportError: cannot import name 'UTC' from 'datetime'
ERROR tests/test_known_types.py
ERROR tests/test_pg_json.py
!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!

Fixes #10.

Fix

Keep the declared 3.10 support and replace datetime.UTC with timezone.utc (available since Python 3.2):

  • tests/test_pg_json.py — import timezone, use tzinfo=timezone.utc
  • tests/test_known_types.py — drop the redundant UTC import (file already imported timezone), use tzinfo=timezone.utc
  • CHANGES.md — changelog entry

Verification

All 80 tests in both affected files pass locally.

🤖 Generated with Claude Code

datetime.UTC was added in Python 3.11, but the package declares
requires-python = ">=3.10" and ships the 3.10 classifier. Two test
files imported datetime.UTC, breaking test collection on 3.10:

    ImportError: cannot import name 'UTC' from 'datetime'

Replace with timezone.utc (available since 3.2). Fixes #10.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jensens jensens merged commit 1c2d96c into main Jun 23, 2026
6 checks passed
@jensens jensens deleted the fix/py310-utc-import branch June 23, 2026 11:00
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.

CI red on main: tests import datetime.UTC, incompatible with Python 3.10

1 participant