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

Support Python 3.10 type unions #75

Merged
merged 1 commit into from Feb 24, 2022
Merged

Support Python 3.10 type unions #75

merged 1 commit into from Feb 24, 2022

Conversation

jcrist
Copy link
Owner

@jcrist jcrist commented Feb 24, 2022

I thought these already worked, but they didn't. Type unions using the
int | None syntax create a types.UnionType object, not a
typing.Union object. Unfortunately types.UnionType doesn't define
__origin__ (like all other generic types do), so this wasn't being
properly handled by the previous logic. This PR fixes this and adds a
test for Python 3.10+.

I thought these already worked, but they didn't. Type unions using the
`int | None` syntax create a `types.UnionType` object, not a
`typing.Union` object. Unfortunately `types.UnionType` doesn't define
`__origin__` (like all other generic types do), so this wasn't being
properly handled by the previous logic. This PR fixes this and adds a
test for Python 3.10+.
@jcrist jcrist merged commit df9a3b0 into master Feb 24, 2022
@jcrist jcrist deleted the 310-union-types branch February 24, 2022 19:02
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.

None yet

1 participant