fix: use timezone.utc instead of datetime.UTC for Python 3.10 compat#11
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI is red on
main: test collection fails on Python 3.10 because two test files importdatetime.UTC, which was only added in Python 3.11. The package declaresrequires-python = ">=3.10"and ships the 3.10 classifier, so this is a genuine compatibility gap.Fixes #10.
Fix
Keep the declared 3.10 support and replace
datetime.UTCwithtimezone.utc(available since Python 3.2):tests/test_pg_json.py— importtimezone, usetzinfo=timezone.utctests/test_known_types.py— drop the redundantUTCimport (file already importedtimezone), usetzinfo=timezone.utcCHANGES.md— changelog entryVerification
All 80 tests in both affected files pass locally.
🤖 Generated with Claude Code