Infer `python_version` from `project.requires-python` when using pyproject.toml
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how mypy reads its configuration from pyproject.toml and resolves the [mypy] python_version option. The change is complete when an unspecified value is derived from project.requires-python, while an explicitly configured python_version still takes precedence; compare the intended behavior with ruff.target-version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100