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

ImportError: cannot import name 'TypeVarDef' from 'mypy.types' #11767

Closed
adam-pawluczuk opened this issue Dec 16, 2021 · 2 comments
Closed

ImportError: cannot import name 'TypeVarDef' from 'mypy.types' #11767

adam-pawluczuk opened this issue Dec 16, 2021 · 2 comments
Labels
bug mypy got something wrong

Comments

@adam-pawluczuk
Copy link

Bug Report

TypeVarDef raises an ImportError.

To Reproduce

  1. On Python 3.8.9, when doing:

from mypy.types import TypeVarDef

I get this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TypeVarDef' from 'mypy.types' (/Users/username/Library/Python/3.8/lib/python/site-packages/mypy/types.py)

Expected Behavior

No errors.

Actual Behavior

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TypeVarDef' from 'mypy.types' (/Users/username/Library/Python/3.8/lib/python/site-packages/mypy/types.py)

Your Environment

  • Mypy version used: 0.920
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.8.9
  • Operating system and version: MacOS 12.1
@adam-pawluczuk adam-pawluczuk added the bug mypy got something wrong label Dec 16, 2021
@hauntsaninja
Copy link
Collaborator

Yes, see #6617 (comment)

If you're coming from pydantic, you can fix it by doing what I suggest here: pydantic/pydantic#3175 (comment)

@adam-pawluczuk
Copy link
Author

adam-pawluczuk commented Dec 16, 2021

Thank you for the link!

I believe the issue comes from pydantic:

https://github.com/samuelcolvin/pydantic/blob/master/pydantic/mypy.py#L62

In our codebase we do not import TypeVarDef anywhere.

Created an issue for pydantic:
pydantic/pydantic#3528

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