Skip to content

[stubgen] Preserve PEP 604 Unions in generated pyi files#14601

Merged
hauntsaninja merged 1 commit intopython:masterfrom
hamdanal:stubgen-union
Feb 7, 2023
Merged

[stubgen] Preserve PEP 604 Unions in generated pyi files#14601
hauntsaninja merged 1 commit intopython:masterfrom
hamdanal:stubgen-union

Conversation

@hamdanal
Copy link
Copy Markdown
Collaborator

@hamdanal hamdanal commented Feb 3, 2023

When a PEP 604 Union exists in the runtime, stubgen was generating a Union[...] syntax without importing Union from typing. With this change, stubgen preserves the |-unions in the output.

Fixes #12929
Closes #13428
Ref #12920

When a PEP 604 Union exists in the runtime, stubgen was generating a
`Union[...]` syntax without importing `Union` from `typing`. With this
change, stubgen preserves the ` | `-unions in the output.

Fixes python#12929
Closes python#13428
Ref python#12920
Copy link
Copy Markdown
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thank you!

@hauntsaninja hauntsaninja merged commit 725214b into python:master Feb 7, 2023
@hamdanal hamdanal deleted the stubgen-union branch February 10, 2023 19:01
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.

stubgen: import Union if generated stub code includes

2 participants