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

NoReturn should be assignable to any type #2921

Closed
erictraut opened this issue Jan 23, 2022 Discussed in #2920 · 2 comments
Closed

NoReturn should be assignable to any type #2921

erictraut opened this issue Jan 23, 2022 Discussed in #2920 · 2 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@erictraut
Copy link
Collaborator

Discussed in #2920

Originally posted by JelleZijlstra January 22, 2022
I was exploring pyright's treatment of NoReturn (in preparation for adding and documenting typing.Never) and noticed that pyright allows passing NoReturn to parameters of type object. For example, this typechecks:

def f(x: NoReturn):
    repr(x)  # repr() takes object

Is this an intentional behavior? It's not what I expected on first principles but it seems useful in practice.

@erictraut erictraut added the bug Something isn't working label Jan 23, 2022
@erictraut
Copy link
Collaborator Author

As discussed, NoReturn should act as a bottom type and is therefore assignable to all other types. Currently, pyright does not handle this correctly. This will be fixed in the next release.

@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Jan 23, 2022
@erictraut
Copy link
Collaborator Author

This is included in pyright 1.1.215, which I just published. It will also be included in the next release of pylance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant