Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[red-knot] Fallback to
requires-python
if no python-version
is sp…
…ecified (#16028) ## Summary Add support for the `project.requires-python` field in `pyproject.toml` files. Fall back to the resolved lower bound of `project.requires-python` if the `environment.python-version` field is `None` (or more accurately, initialize `environment.python-version with `requires-python`'s lower bound if left unspecified). ## UX design There are two options on how we can handle the fallback to `requires-python`'s lower bound: 1. Store the resolved lower bound in `environment.python-version` if that field is `None` (Implemented in this PR) 2. Store the `requires-python` constraint separately. There's no observed difference unless a user-level configuration (or any other inherited configuration is used). Let's discuss it on the given example **User configuration** ```toml [environment] python-version = "3.10" ``` **Project configuration (`pyproject.toml`)** ```toml [project] name = "test" requires-python = ">= 3.12" [tool.knot] # No environment table ``` The resolved version for 1. is 3.12 because the `requires-python` constraint precedence takes precedence over the `python-version` in the user configuration. 2. resolves to 3.10 because all `python-version` constraints take precedence before falling back to `requires-python`. Ruff implements 1. It's also the easier to implement and it does seem intuitive to me that the more local `requires-python` constraint takes precedence. ## Test plan Added CLI and unit tests.
- Loading branch information