Skip to content

Infer python_version from project.requires-python when using pyproject.toml #19349

Open
@stephenfin

Description

@stephenfin

Feature

Per the docs, the [mypy] python_version configuration option defaults to "the version of the Python interpreter used to run mypy." We should change this so that it is instead derived from the project.requires-python when the mypy configuration itself is defined in a pyproject.toml file, similar to what ruff currently does for ruff.target-version.

Pitch

Using the system Python version is almost always the wrong thing to do when running against a package that specifies a minimum supported Python version via their pyproject.toml file. This necessitates use of the [mypy] python_version option, even though it (perhaps partially) duplicates information already available. Automatically detecting a value for [mypy] python_version when not explicitly specified would be a neat little UX win.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions