Skip to content

[1.16 apparent regression] mypy 1.16 fails to analyze pydantic 2.11.5 (succeeded in mypy 1.15) #19209

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
DaveShuckerow opened this issue Jun 2, 2025 · 2 comments
Labels

Comments

@DaveShuckerow
Copy link

DaveShuckerow commented Jun 2, 2025

Bug Report

mypy 1.16 fails to analyze code that imports pydantic 2.11.5. Mypy analysis succeeded in mypy 1.15.

To Reproduce

import pydantic # I was using pydantic 2.11.5

Expected Behavior

mypy should successfully analyze the file.

Actual Behavior

[ERROR] Completed: Typecheck using MyPy - mypy - mypy failed (exit code 2).
.cache/pex_root/venvs/1/0e03c948bbef7584e6803ffeda803caff33dd8c6/e78a64e86d7066bde1606f95b893e7cfa75dbda9/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py:17: error: Cannot find implementation or library stub for module named "rich.console"  [import-not-found]
.cache/pex_root/venvs/1/0e03c948bbef7584e6803ffeda803caff33dd8c6/e78a64e86d7066bde1606f95b893e7cfa75dbda9/lib/python3.10/site-packages/pydantic/_internal/_core_utils.py:17: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

packages/package_name/src/file.py: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 1.16.0

Your Environment

  • Mypy version used: 1.16
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.10.16
@DaveShuckerow DaveShuckerow added the bug mypy got something wrong label Jun 2, 2025
@sterliakov sterliakov added crash and removed bug mypy got something wrong labels Jun 3, 2025
@sterliakov
Copy link
Collaborator

Can't reproduce - with or without pydantic plugin, with or without --strict, checking import pydantic produces "no issues found". Are there any other relevant details?

cd "$(mktemp -d)"
uv venv --python 3.10 && . .venv/bin/activate
uv pip install 'mypy==1.16.0' 'pydantic==2.11.5'

cat <<EOF > mypy.ini
[mypy]
plugins = pydantic.mypy
EOF

printf 'import pydantic\n' > foo.py

mypy foo.py
# Success: no issues found in 1 source file

Could you post the traceback (--show-traceback flag) and try doing the same using the master version (pip install git+https://github.com/python/mypy)?

@DaveShuckerow
Copy link
Author

I tried the latest mypy master today, and I'm no longer getting this issue.

I'll stick downgrade from 1.16 to 1.15 until the 1.17 release comes out.

Thank you Stanislav & team!

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

2 participants