⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@Viicos
Copy link
Contributor

@Viicos Viicos commented Jan 12, 2026

The runtime definition only has a default of None to lazily import annotationlib: https://github.com/python/cpython/blob/66e1399311c17684c6e26f5d9d9603fbd0717d0d/Lib/typing.py#L2365-L2367.

While providing None explicitly is technically valid, it's best to have the value present in the stub so that users can easily know the default value.

@github-actions

This comment has been minimized.

@srittau
Copy link
Collaborator

srittau commented Jan 12, 2026

This needs stubtest allowlist entries.

@srittau srittau requested a review from JelleZijlstra January 12, 2026 21:22
@JelleZijlstra
Copy link
Member

I'd prefer to keep None because that's the actual runtime default, regardless of the motivation.

@Viicos
Copy link
Contributor Author

Viicos commented Jan 13, 2026

I'd find it a bit unfortunate but I don't have strong opinions. I'm wondering if None should in fact not be documented at all, so that if the lazy loading of the annotationlib module goes away, it can be switched back without maintaining backwards compatibility for None.

Or, could we at least have a comment in the stubs stating what is the actual default?

@srittau
Copy link
Collaborator

srittau commented Jan 13, 2026

Or, could we at least have a comment in the stubs stating what is the actual default?

That sounds like a good compromise to me.

@JelleZijlstra
Copy link
Member

A comment would be fine!

@Viicos Viicos changed the title Fix type hint of format parameter in typing.get_type_hints() Add comment indicating default value of format parameter in typing.get_type_hints() Jan 13, 2026
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit 82c9b97 into python:main Jan 13, 2026
63 checks passed
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.

3 participants