-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Render union types using |
#413
Comments
I am in total agreement with @flying-sheep. This would be a really great improvement. |
I'll review a PR if someone puts one in 👍 doing the change. |
Thanks @gaborbernat. @flying-sheep are you open to creating a PR for what you proposed? |
I would, but #418 already exists. Also, I don‘t think it needs to be an option, it should just be how things are done, no? |
That was a quick PR! @flying-sheep I agree with you regarding the option... I'll leave a comment on the PR. |
Python encourages using
|
overUnion
andOptional
. s-a-t should therefore render unions that way by default.See here for more context.
Of note is the argument that
Optional
is actually misleading, since it implies something that doesn’t exist in Python:missing(param)
, which returnsTRUE
only when the function was called without specifyingparam
.param: int | None = 4
is perfectly meaningful, while the same expressed asparam: Optional[int] = 4
is very confusing: TheOptional
seems to relate to the fact that the parameter can be left out when calling the function, but actually means that you can specifyparam=None
to override the default of4
. Weird!The text was updated successfully, but these errors were encountered: