Skip to content

Wrong version of typing-extensions used. #12253

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

Closed
ngnpope opened this issue Feb 25, 2022 · 1 comment
Closed

Wrong version of typing-extensions used. #12253

ngnpope opened this issue Feb 25, 2022 · 1 comment
Labels
bug mypy got something wrong

Comments

@ngnpope
Copy link
Contributor

ngnpope commented Feb 25, 2022

Bug Report

I was attempt to use assert_never() from typing-extensions>=4.1.0 but I get the following when running mypy:

example.py:1: error: Module "typing_extensions" has no attribute "assert_never"  [attr-defined]

I noticed that the following file exists in typeshed/stdlib even though typing-extensions is not part of the standard library:

https://github.com/python/mypy/blob/master/mypy/typeshed/stdlib/typing_extensions.pyi

This prevents use of a newer version of typing_extensions with mypy because the types are always fixed at the version distributed with mypy. This is somewhat surprising and the error is very obscure.

To Reproduce

(Write your steps here:)

  1. Install typing-extensions>=4.1.0
  2. Add from typing_extensions import assert_never
  3. Run mypy

Expected Behavior

mypy recognises imports of new things from newer versions of typing-extensions.

Actual Behavior

mypy complains that assert_never() doesn't exist in typing-extensions.

Your Environment

  • Mypy version used: 0.931
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): pretty, strict, show-error-codes, warn-unreachable
  • Python version used: 3.9
  • Operating system and version: Linux
@ngnpope ngnpope added the bug mypy got something wrong label Feb 25, 2022
@JelleZijlstra
Copy link
Member

Mypy bundles its own copy of typeshed, and the most recent release does not yet include typing_extensions.assert_never. The next release will.

In the meantime, you can use --custom-typeshed-dir to point to an updated copy of typeshed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants