mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
[ty] document how the default value for python-version
is determined (#18549)
Co-authored-by: detachhead <detachhead@users.noreply.github.com> Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
parent
07cb84426d
commit
ae2150bfa3
3 changed files with 25 additions and 7 deletions
15
crates/ty/docs/configuration.md
generated
15
crates/ty/docs/configuration.md
generated
|
@ -106,9 +106,18 @@ The version should be specified as a string in the format `M.m` where `M` is the
|
|||
and `m` is the minor (e.g. `"3.0"` or `"3.6"`).
|
||||
If a version is provided, ty will generate errors if the source code makes use of language features
|
||||
that are not supported in that version.
|
||||
It will also understand conditionals based on comparisons with `sys.version_info`, such
|
||||
as are commonly found in typeshed to reflect the differing contents of the standard
|
||||
library across Python versions.
|
||||
|
||||
If a version is not specified, ty will try the following techniques in order of preference
|
||||
to determine a value:
|
||||
1. Check for the `project.requires-python` setting in a `pyproject.toml` file
|
||||
and use the minimum version from the specified range
|
||||
2. Check for an activated or configured virtual environment
|
||||
and use the Python version of that environment
|
||||
3. Fall back to the default value (see below)
|
||||
|
||||
For some language features, ty can also understand conditionals based on comparisons
|
||||
with `sys.version_info`. These are commonly found in typeshed, for example,
|
||||
to reflect the differing contents of the standard library across Python versions.
|
||||
|
||||
**Default value**: `"3.13"`
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue