Skip to content

Conversation

@RazerM
Copy link
Contributor

@RazerM RazerM commented Nov 11, 2025

Fixes #19

date: Date,
time: Time[Optional[_tzinfo]],
tzinfo: Optional[_tzinfo] = None,
tzinfo: Optional[_tzinfo] = _missing, # type: ignore[assignment]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some context for the sentinel I used here:

The Python implemention of CPython's datetime module uses True for the sentinel, but that is not part of the API and doesn't work with the builtin module:

❯ uv run --isolated --no-project -p 3.14 python
Python 3.14.0 (main, Oct 28 2025, 12:03:45) [Clang 20.1.4 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _datetime
>>> import _pydatetime
>>> _pydatetime.datetime.combine(_pydatetime.date.today(), _pydatetime.time(tzinfo=_pydatetime.UTC), True)
datetime.datetime(2025, 11, 11, 0, 0, tzinfo=datetime.timezone.utc)
>>> _datetime.datetime.combine(_datetime.date.today(), _datetime.time(tzinfo=_datetime.UTC), True)
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    _datetime.datetime.combine(_datetime.date.today(), _datetime.time(tzinfo=_datetime.UTC), True)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: tzinfo argument must be None or of a tzinfo subclass, not type 'bool'

@glyph glyph merged commit 1dcafd5 into glyph:trunk Nov 12, 2025
13 checks passed
@glyph
Copy link
Owner

glyph commented Nov 12, 2025

I think there might be a slightly better way to express this, but the update is clearly correct

@RazerM RazerM deleted the fix/datetime-combine branch November 12, 2025 21:45
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.

DateTime.combine with an aware time returns a naive datetime

2 participants