Skip to content

Add NoReturn type#397

Merged
ilevkivskyi merged 2 commits into
python:masterfrom
ilevkivskyi:add-noreturn
Mar 27, 2017
Merged

Add NoReturn type#397
ilevkivskyi merged 2 commits into
python:masterfrom
ilevkivskyi:add-noreturn

Conversation

@ilevkivskyi

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

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

@ilevkivskyi

Copy link
Copy Markdown
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

gvanrossum commented Mar 17, 2017

Copy link
Copy Markdown
Member

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