Repository navigation
Error importing plugin "pydantic.mypy": cannot import name 'Sentinel' from 'typing_extensions' #380
Description
Diagnostic Data
- Python version (& distribution if applicable, e.g., Anaconda): Python 3.14.0 (standard CPython)
- Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): venv (managed by uv)
- Operating system (and version): Linux Ubuntu 24.04.2 LTS (in dev container)
- Version of tool extension you are using: ms-python.mypy-type-checker@2025.2.0
Behaviour
Expected Behavior
When using pydantic.mypy plugin in pyproject.toml, the mypy extension should load the plugin successfully and perform type checking with pydantic model validation, just as it does when running mypy from the command line.
Actual Behavior
The extension fails with the following error:
pyproject.toml:1:1:1:1: error: Error importing plugin "pydantic.mypy": cannot import name 'Sentinel' from 'typing_extensions' (/home/vscode/.vscode-server/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/typing_extensions.py) [misc]
The error indicates that the bundled typing_extensions in the extension is missing the Sentinel type, which is required by the pydantic.mypy plugin (added in typing_extensions 4.14.0).
Reproduction Steps:
- Create a Python project with the following
pyproject.toml:[project] dependencies = [ "pydantic>=2.12.4", ] [dependency-groups] dev = [ "mypy>=1.18.0", ] [tool.mypy] strict = true plugins = ["pydantic.mypy"]
- Install dependencies and create a virtual environment:
uv sync
- Open any Python file in the project that uses pydantic models.
- Observe the error in the mypy output panel.
Logs:
2025-11-07 09:58:17.371 [info] [Trace - 9:58:17 AM] Received notification 'window/logMessage'.
2025-11-07 09:58:17.371 [info] Params: {
"type": 4,
"message": "pyproject.toml: [mypy]: Unrecognized option: exclude_gitignore = True\npyproject.toml:1:1:1:1: error: Error importing plugin \"pydantic.mypy\": cannot import name 'Sentinel' from 'typing_extensions' (/home/vscode/.vscode-server/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/typing_extensions.py) [misc]\n"
}
2025-11-07 09:58:17.371 [info] pyproject.toml: [mypy]: Unrecognized option: exclude_gitignore = True
pyproject.toml:1:1:1:1: error: Error importing plugin "pydantic.mypy": cannot import name 'Sentinel' from 'typing_extensions' (/home/vscode/.vscode-server/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/typing_extensions.py) [misc]
Outcome When Attempting Debugging Steps:
Did running it from the command line work? YES
$ uv run mypy .
Success: no issues found in 27 source filesThe exact same configuration with plugins = ["pydantic.mypy"] works fine when running mypy 1.18.2 from the command line with pydantic 2.12.4 installed in the project's virtual environment.
This confirms the issue is specific to the VS Code extension's bundled libraries, not the mypy configuration or the project setup.
Extra Details
- Installed versions in project:
- mypy: 1.18.2
- pydantic: 2.12.4
- typing_extensions: 4.12.2
- VS Code: 1.105.1
- Project structure: Using
uvas package manager withpyproject.toml - Mypy configuration: In
pyproject.tomlunder[tool.mypy] - Workaround: Commenting out the
pydantic.mypyplugin resolves the extension error:However, this removes the enhanced type checking that pydantic's mypy plugin provides.[tool.mypy] strict = true # plugins = ["pydantic.mypy"]
Activity
vlad397 commentedon Nov 11, 2025
Same problem. I found that if you delete "/.vscode-server/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/typing_extensions.py" everythins is working fine. Filename is conflicting with the library "typing_extensions". Ofc deleting is not a solution, just wanted to point it out.
installed versions:
alschall commentedon Nov 28, 2025
I noticed that the VSCode extension was loading a mypy version (1.15.0) that was different to the one in my env (1.18.2).
Setting
mypy-type-checker.importStrategyto env fixed it for me:vlad397 commentedon Dec 1, 2025
Albrecht Schall (@alschall) , nice! Helped me a lot
ademoverflow commentedon Dec 27, 2025
Albrecht Schall (@alschall) Thanks !! That helped a lot.
fix: run editor mypy from the venv so the pydantic plugin loads