-
Notifications
You must be signed in to change notification settings - Fork 237
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
Add explanation of singletons in unions to PEP484 #240
Conversation
else: # At this point typechecker knows that x can only have type int | ||
return x * 2 | ||
|
||
Since the subclasses of ``Enum`` could not be further subclassed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot
Thanks! Some language nits. I wonder if we should add another example showing an enum with multiple values? |
I have made corrections and added another example. I think it clarifies that it is not necessary to make many |
token = 0 | ||
_empty = Empty.token | ||
|
||
def func(x: Union[int, None, Empty]=_empty) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: add spaces around =
.
@JukkaL Done. |
By Ivan Levkivskyi (python/typing#240).
Pushed to the peps repo and filed python/mypy#1803. Maybe now that the peps repo has moved to GitHub we should switch to doing PRs there? |
Thanks!
Yes, I think we could switch to new peps repo. By the way, what are the plans for PEP484, will it be provisional in 3.6? Or will it "graduate" soon? |
I would like PEP 484 to drop the provisional status for 3.6, but we have to
discuss this on python-dev.
For asyncio we did two provisional release (3.4 and 3.5) but IMO that was
too long (and yet not long enough -- Yury recently asked me to extend that
to 3.6 as well).
|
I tried to keep discussion to a minimum, only including simple examples. I think it is better to add this section right after discussion of Optional, that is actually also a Union with a singleton type (NoneType).