-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
stubgen: use X | Y
/ X | None
instead of Union[X, Y]
/ Union[X, None]
#12920
Comments
X | Y
/ X | None
instead of Union[X, Y]
/ Optional[X]
X | Y
/ X | None
instead of Union[X, Y]
/ Union[X, None]
Anyway, it is weird that |
@eggplants if stubgen doesn't import Union when it should, please open a separate issue with a reproducer. We should definitely fix that, and I suspect it'll be easy. I'm a little more uncertain about this issue, since mypy still has a few bugs where it doesn't accept |
@JelleZijlstra Thank you. Created: #12929 |
We could safely teach stubgen to use PEP 604 in non-runtime contexts. But that might be more complicated than it's worth; it might be better to wait until mypy has full PEP-604 support. |
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
Feature
I would like to let stubgen use
X | Y
/X | None
instead ofUnion[X, Y]
/Union[X, None]
.Pitch
Now:
Expect:
The text was updated successfully, but these errors were encountered: