Skip to content

--python-executable doesn't discover plugins #21621

@flexagoon

Description

@flexagoon

Bug Report

When using --python-executable with globally installed mypy, it discovers the packages installed in the virtualenv, but not the installed plugins

To Reproduce

  1. Use globally installed mypy
  2. python -m venv .venv
  3. .venv/bin/pip install pydantic
  4. echo pass > main.py
  5. In pyproject.toml:
[tool.mypy]
plugins = ["pydantic.mypy"]
  1. mypy --python-executable .venv/bin/python main.py

Expected Behavior

It should pass with no errors, just like it does when installed inside of the virtualenv

Actual Behavior

pyproject.toml:1: error: Error importing plugin "pydantic.mypy": No module named 'pydantic'  [misc]
Found 1 error in 1 file (errors prevented further checking)

Your Environment

  • Mypy version used: 2.1.0
  • Python version used: 3.14.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions