8000 Mypy plugin AssertionError with mypy 0.930 · Issue #3580 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content
Mypy plugin AssertionError with mypy 0.930 #3580
@paul-sud

Description

@paul-sud

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']

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0