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

Type annotations missing for assert_never? #1176

Closed
bluenote10 opened this issue May 5, 2022 · 4 comments
Closed

Type annotations missing for assert_never? #1176

bluenote10 opened this issue May 5, 2022 · 4 comments
Labels
topic: other Other topics not covered

Comments

@bluenote10
Copy link

According to tracking issue python/mypy#5818, assert_never was introduced in typing_extensions version 4.1.0. At runtime, this clearly seems to work, which I can verify via:

python -c "from typing_extensions import assert_never"

However if I type check the code with mypy it complains at the line of the import:

error: Module "typing_extensions" has no attribute "assert_never"

I'm not sure if this an issue with typing_extensions or mypy though.

In any case, assert_never is supposed to have runtime behavior (to raise an assertion), i.e., it is not something that is supposed to be hidden behind a TYPE_ASSERTION barrier.

@bluenote10 bluenote10 added the topic: other Other topics not covered label May 5, 2022
@AlexWaygood
Copy link
Member

This should work fine if you upgrade to mypy 0.950 :)

@AlexWaygood
Copy link
Member

AlexWaygood commented May 5, 2022

The issue is that mypy uses typing_extensions.pyi in typeshed for typing_extensions, so if something is missing from the typeshed stub for typing_extensions, mypy doesn't know about it, even if it exists at runtime. Mypy <=0.942 uses an out-of-date version of the typeshed stub.

@bluenote10
Copy link
Author

Indeed, works fine with mypy 0.950, thanks and sorry for the noise!

@AlexWaygood
Copy link
Member

Indeed, works fine with mypy 0.950, thanks and sorry for the noise!

No worries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: other Other topics not covered
Projects
None yet
Development

No branches or pull requests

2 participants