Skip to content

Fix Meta.tz stub annotation to bool | None - #1179

Merged
Siyet merged 3 commits into
msgspec:mainfrom
vmphase:fix/meta-tz-stub-annotation
Sep 14, 2026
Merged

Siyet merged 3 commits into
msgspec:mainfrom
vmphase:fix/meta-tz-stub-annotation

Conversation

@vmphase

@vmphase vmphase commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

The C implementation validates it with ensure_is_bool and the docstring documents it as tz: bool, optional.

import msgspec

m = msgspec.Meta(tz=True)

is_tz_aware: bool = m.tz
# Type "int | None" is not assignable to declared type "bool"
# "int" is not assignable to "bool" (basedpyright reportAssignmentType)

print(f"m.tz = {m.tz!r}, runtime = {type(m.tz).__name__}")
# m.tz = True, runtime = bool

@Siyet Siyet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thx for the fix! Please add assert_type(c.tz, bool | None) to check_meta_attributes so the getter type is covered by a regression test

@vmphase

vmphase commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

check_meta_attributes

Pushed the changes!

@Siyet
Siyet added this pull request to the merge queue Sep 14, 2026
Merged via the queue into msgspec:main with commit 1e8646d Sep 14, 2026
27 of 28 checks passed
@vmphase
vmphase deleted the fix/meta-tz-stub-annotation branch September 14, 2026 12:40
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.

2 participants