Skip to content

Add NoReturn type #397

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

Merged
merged 2 commits into from
Mar 27, 2017
Merged

Add NoReturn type #397

merged 2 commits into from
Mar 27, 2017

Conversation

ilevkivskyi
Copy link
Member

Fixes #165

Note that here I prohibit List[NoReturn], but maybe we should allow this in order to allow Union[int, NoReturn] and/or Callable[..., NoReturn] (or make exceptions for the latter two).

As discussed in #165, this PR should wait until Python 3.6.1 is released.

@JelleZijlstra
Copy link
Member

What would the use of Union[int, NoReturn] be? We could type functions that either return int or throw an exception (e.g., the int constructor) this way, but I'm not sure that would enable better type checking.

Callable[..., NoReturn] makes more logical sense to me, but it doesn't seem like something that's often useful in practice.

@gvanrossum
Copy link
Member

I think we've learned in the past that typing.py should be kept simple, stupid. A static checker can reject List[NoReturn].

@ilevkivskyi
Copy link
Member Author

@gvanrossum

I think we've learned in the past that typing.py should be kept simple, stupid.

Yes, right :-) Since this case is not obvious, we can let type checkers decide.

@gvanrossum
Copy link
Member

Code LGTM. I wonder though if we should get Mark Shannon's view of the PEP 484 changes first.

@ilevkivskyi
Copy link
Member Author

There is no hurry with this (this could not go into 3.6.1), let us first sort out the PEP, and then I could merge this.

@gvanrossum
Copy link
Member

gvanrossum commented Mar 17, 2017

Feel free to merge as soon as 3.6.1 is released. (And typing 3.6.1 has been pushed to PyPI.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants