Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make typing hints work with Python 3.9 to 3.11 #183

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

claui
Copy link
Contributor

@claui claui commented Feb 11, 2025

This PR changes typing hints to allow static type checkers to work if client code uses Python 3.9 to Python 3.11.

Background:

The type statement is new in Python 3.12. For backwards compatibility, type aliases can also be created through simple assignment: […]

I have tested the change with client code in 3.9, 3.10, 3.11, 3.12, and 3.13, and found that this PR fixes the issues in all affected versions (3.9 through 3.11).

This PR, together with PR #177, fixes issue #176.

Change typing hints to allow static type checkers to work if client code
uses Python 3.9 to Python 3.11.

Background:

> The type statement is new in Python 3.12. For
> backwards compatibility, type aliases can also
> be created through simple assignment:

Link: https://docs.python.org/3/library/typing.html
@claui
Copy link
Contributor Author

claui commented Feb 11, 2025

Turns out that I had to leave one of the type statements in place so test_union_as_type_alias_recursive doesn’t break.

However, that unit test is only for Python 3.12 or above anyway, so it shouldn’t have any impact on lower versions.

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.

1 participant