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

Mypy plugin AssertionError with mypy 0.930 #3580

Closed
3 tasks done
paul-sud opened this issue Dec 26, 2021 · 2 comments
Closed
3 tasks done

Mypy plugin AssertionError with mypy 0.930 #3580

paul-sud opened this issue Dec 26, 2021 · 2 comments
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@paul-sud
Copy link

Checks

  • I added a descriptive title to this issue
  • I have searched (google, github) for similar issues and couldn't find anything
  • I have read and followed the docs and still think this is a bug

Bug

When using the latest alpha release with mypy==0.930 I get the following error:

https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.930
Traceback (most recent call last):
  File "mypy/semanal.py", line 5132, in accept
  File "mypy/nodes.py", line 1005, in accept
  File "mypy/semanal.py", line 1105, in visit_class_def
  File "mypy/semanal.py", line 1184, in analyze_class
  File "mypy/semanal.py", line 1193, in analyze_class_body_common
  File "mypy/semanal.py", line 1253, in apply_class_plugin_hooks
  File "pydantic/mypy.py", line 114, in pydantic.mypy.PydanticPlugin._pydantic_model_class_maker_callback
  File "pydantic/mypy.py", line 200, in pydantic.mypy.PydanticModelTransformer.transform
  File "pydantic/mypy.py", line 341, in pydantic.mypy.PydanticModelTransformer.add_initializer
  File "pydantic/mypy.py", line 657, in pydantic.mypy.add_method
  File "mypy/semanal.py", line 4538, in named_type
  File "mypy/semanal.py", line 4505, in lookup_fully_qualified
AssertionError: 
/Users/paul/.cache/pre-commit/repo4nch0291/py_env-python3.9/lib/python3.9/site-packages/pydantic/env_settings.py:21: : note: use --pdb to drop into pdb

The behavior of named_type changed in python/mypy#11332 which causes the issue. Calls to named_type in the plugin should use builtins.X instead of __builtins__.X for the fullname arg.

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.9.0a2
            pydantic compiled: True
                 install path: /Users/paul/.cache/pre-commit/repo4nch0291/py_env-python3.9/lib/python3.9/site-packages/pydantic
               python version: 3.9.6 (default, Aug 18 2021, 18:03:48)  [Clang 11.0.3 (clang-1103.0.32.62)]
                     platform: macOS-10.16-x86_64-i386-64bit
     optional deps. installed: ['typing-extensions']
@paul-sud paul-sud added the bug V1 Bug related to Pydantic V1.X label Dec 26, 2021
@PrettyWood
Copy link
Member

PrettyWood commented Dec 26, 2021

Hi @paul-sud
Issue already tackled (see #3573 and more specifically 7168f4c)

@paul-sud
Copy link
Author

Fantastic, thanks. I'll close this out then. I guess you can reopen if you want to use it to track alongside the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

No branches or pull requests

2 participants