Skip to content

Type numeric UTC offsets for now() - #1097

Open
emme1t wants to merge 1 commit into
python-pendulum:masterfrom
emme1t:fix/now-offset-annotations-607
Open

emme1t wants to merge 1 commit into
python-pendulum:masterfrom
emme1t:fix/now-offset-annotations-607

Conversation

@emme1t

@emme1t emme1t commented Nov 21, 2026

Copy link
Copy Markdown

Fixes #607.

pendulum.now(5.5) already returns a datetime at UTC+05:30. Its annotation rejected that call, and the DateTime.now overloads also rejected numeric offsets. Both entry points now describe the timezone values accepted at runtime, including fractional hour offsets and standard-library tzinfo objects. The class method keeps its Self return type for subclasses.

  • Added tests for positive and negative fractional offsets and a standard-library ZoneInfo.
  • Updated the instantiation guide with a fractional offset example.

On Windows with TZ=UTC, the full test suite passed (1,870 passed, 5 skipped). Mypy passed on all 228 source and test files. A separate typed caller covering both entry points and a subclass produced eight diagnostics on master and passed with this change.

This branch has not been deployed

No deployments
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.

Incomplete types for now(tz=...) methods

1 participant