Conversation
|
It looks like right now there's no good way to alias |
|
This is rather because of mypy_extensions.py in Mypy master not containing NoReturn yet. Mypy doesn't even look at the stub. Land python/mypy#2637 and it should work. |
|
It's actually the other way round: if there's a stub, mypy doesn't look at the corresponding I worked around the aliasing issue here by using |
|
Right, I thought there's something special going on about mypy_extensions, just like lib-typing over typing.pyi. |
| # Return type that indicates a function does not return. | ||
| # This type is equivalent to the None type, but the no-op Union is necessary to | ||
| # distinguish the None type from the None value. | ||
| NoReturn = Union[None] |
There was a problem hiding this comment.
I am not sure I understand this. NoReturn is different from the NoneType, the latter is a type with one value, while the former is a type with no values, a.k.a. "error type" or "bottom type". Maybe it would be better to write class NoReturn: ...?
@gvanrossum What do you think about this?
There was a problem hiding this comment.
The intent is to not disrupt typecheckers that don't yet support this (as it's not yet part of PEP 484).
Adds
mypy_extensions.NoReturnas an alias for None and changes the annotation of some standard functions which don't return. Mypy will soon understand that this indicates a function cannot return (which is important for the--warn-no-returnflag, which we're considering enabling by default).