mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:53 +00:00
Recommend project.requires-python
over target-version
(#8513)
**Summary** Recommend the standardized, shared `project.requires-python` over ruff's custom `target-version`. See https://mastodon.social/deck/@davidism@mas.to/111347072204727710 **Test Plan** Docs only change
This commit is contained in:
parent
82c3c513d2
commit
3c8d9d45fb
2 changed files with 13 additions and 5 deletions
|
@ -298,10 +298,18 @@ pub struct Options {
|
||||||
/// For example, to represent supporting Python >=3.10 or ==3.10
|
/// For example, to represent supporting Python >=3.10 or ==3.10
|
||||||
/// specify `target-version = "py310"`.
|
/// specify `target-version = "py310"`.
|
||||||
///
|
///
|
||||||
/// If omitted, and Ruff is configured via a `pyproject.toml` file, the
|
/// If you're already using a `pyproject.toml` file, we recommend
|
||||||
/// target version will be inferred from its `project.requires-python`
|
/// `project.requires-python` instead, as it's based on Python packaging
|
||||||
/// field (e.g., `requires-python = ">=3.8"`). If Ruff is configured via
|
/// standards, and will be respected by other tools. For example, Ruff
|
||||||
/// `ruff.toml` or `.ruff.toml`, no such inference will be performed.
|
/// treats the following as identical to `target-version = "py38"`:
|
||||||
|
///
|
||||||
|
/// ```toml
|
||||||
|
/// [project]
|
||||||
|
/// requires-python = ">=3.8"
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// If both are specified, `target-version` takes precedence over
|
||||||
|
/// `requires-python`.
|
||||||
#[option(
|
#[option(
|
||||||
default = r#""py38""#,
|
default = r#""py38""#,
|
||||||
value_type = r#""py37" | "py38" | "py39" | "py310" | "py311" | "py312""#,
|
value_type = r#""py37" | "py38" | "py39" | "py310" | "py311" | "py312""#,
|
||||||
|
|
2
ruff.schema.json
generated
2
ruff.schema.json
generated
|
@ -649,7 +649,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"target-version": {
|
"target-version": {
|
||||||
"description": "The minimum Python version to target, e.g., when considering automatic code upgrades, like rewriting type annotations. Ruff will not propose changes using features that are not available in the given version.\n\nFor example, to represent supporting Python >=3.10 or ==3.10 specify `target-version = \"py310\"`.\n\nIf omitted, and Ruff is configured via a `pyproject.toml` file, the target version will be inferred from its `project.requires-python` field (e.g., `requires-python = \">=3.8\"`). If Ruff is configured via `ruff.toml` or `.ruff.toml`, no such inference will be performed.",
|
"description": "The minimum Python version to target, e.g., when considering automatic code upgrades, like rewriting type annotations. Ruff will not propose changes using features that are not available in the given version.\n\nFor example, to represent supporting Python >=3.10 or ==3.10 specify `target-version = \"py310\"`.\n\nIf you're already using a `pyproject.toml` file, we recommend `project.requires-python` instead, as it's based on Python packaging standards, and will be respected by other tools. For example, Ruff treats the following as identical to `target-version = \"py38\"`:\n\n```toml [project] requires-python = \">=3.8\" ```\n\nIf both are specified, `target-version` takes precedence over `requires-python`.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/PythonVersion"
|
"$ref": "#/definitions/PythonVersion"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue