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 with pydantic #15675

Closed
andree0 opened this issue Jul 14, 2023 · 3 comments
Closed

Mypy with pydantic #15675

andree0 opened this issue Jul 14, 2023 · 3 comments
Labels

Comments

@andree0
Copy link

andree0 commented Jul 14, 2023

Crash Report

Mypy 1.4.1 not working with pydantic plugin, but 1.3.0 version working.

/home/andrzej/.pyenv/versions/3.11.4/envs/KRZ-3/lib/python3.11/site-packages/pydantic/env_settings.py:22: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
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: 1.4.1
Traceback (most recent call last):
File "mypy/semanal.py", line 6451, in accept
File "mypy/nodes.py", line 1139, in accept
File "mypy/semanal.py", line 1582, in visit_class_def
File "mypy/semanal.py", line 1667, in analyze_class
File "mypy/semanal.py", line 1694, in analyze_class_body_common
File "mypy/semanal.py", line 1777, in apply_class_plugin_hooks
File "pydantic/mypy.py", line 129, in pydantic.mypy.PydanticPlugin._pydantic_model_class_maker_callback
File "pydantic/mypy.py", line 262, in pydantic.mypy.PydanticModelTransformer.transform
File "pydantic/mypy.py", line 441, in pydantic.mypy.PydanticModelTransformer.add_construct_method
TypeError: init() missing required argument 'default' (pos 6)
/home/andrzej/.pyenv/versions/3.11.4/envs/KRZ-3/lib/python3.11/site-packages/pydantic/env_settings.py:22: : note: use --pdb to drop into pdb

To Reproduce

Your Environment

  • Mypy version used: 1.4.1
  • Mypy command-line flags: . or --install-types .
  • Mypy configuration options from pyproject.toml:
[tool.mypy]
    python_version = "3.11"
    ignore_missing_imports = true
    strict_optional = false
    show_traceback = true
    pretty = true
    plugins = [
        "pydantic.mypy",
    ]
    exclude = [
        "lib",
        "venv", # gitlab ci
        ".venv",
    ]
[tool.pydantic-mypy]
    init_forbid_extra = true
    init_typed = true
    warn_required_dynamic_aliases = true
  • Python version used: 3.11.4
  • Operating system and version:
No LSB modules are available.
Distributor ID: Pop
Description:    Pop!_OS 22.04 LTS
Release:        22.04
Codename:       jammy
@andree0 andree0 added the crash label Jul 14, 2023
@JelleZijlstra
Copy link
Member

This is a bug in the mypy plugin that pydantic ships. I believe it was already fixed; you need to upgrade pydantic.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2023
@AlexWaygood
Copy link
Member

(Duplicate of #15485, #15492 and #15573)

@andree0
Copy link
Author

andree0 commented Jul 14, 2023

works with pydantic 1.10.11, I run with 1.10.1 before

@andree0 andree0 closed this as completed Jul 14, 2023
@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants