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

Add explanation of singletons in unions to PEP484 #240

Merged
merged 3 commits into from
Jul 5, 2016

Conversation

ilevkivskyi
Copy link
Member

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).

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,
Copy link
Member

Choose a reason for hiding this comment

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

Cannot

@gvanrossum
Copy link
Member

Thanks! Some language nits.

I wonder if we should add another example showing an enum with multiple values?

@ilevkivskyi
Copy link
Member Author

I have made corrections and added another example. I think it clarifies that it is not necessary to make many Enum's if one wants more than one special value.

token = 0
_empty = Empty.token

def func(x: Union[int, None, Empty]=_empty) -> int:
Copy link
Contributor

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 =.

@ilevkivskyi
Copy link
Member Author

@JukkaL Done.

@gvanrossum gvanrossum merged commit 28c3d32 into python:master Jul 5, 2016
gvanrossum pushed a commit to python/peps that referenced this pull request Jul 5, 2016
@gvanrossum
Copy link
Member

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?

@ilevkivskyi
Copy link
Member Author

Pushed to the peps repo and filed python/mypy#1803.

Thanks!

Maybe now that the peps repo has moved to GitHub we should switch to doing PRs there?

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?

@gvanrossum
Copy link
Member

gvanrossum commented Jul 5, 2016 via email

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.

3 participants