mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
parent
cdbd0bd5cd
commit
8bc7378002
5 changed files with 18 additions and 5 deletions
|
@ -281,8 +281,15 @@ const TYPING_EXTENSIONS_TO_TYPING_311: &[&str] = &[
|
|||
"get_overloads",
|
||||
"overload",
|
||||
"reveal_type",
|
||||
// Introduced in Python 3.11, but `typing_extensions` backports the `frozen_default` argument.
|
||||
// "dataclass_transform",
|
||||
];
|
||||
|
||||
// Python 3.12+
|
||||
|
||||
// Members of `typing_extensions` that were moved to `typing`.
|
||||
const TYPING_EXTENSIONS_TO_TYPING_312: &[&str] = &[
|
||||
// Introduced in Python 3.11, but `typing_extensions` backports the `frozen_default` argument,
|
||||
// which was introduced in Python 3.12.
|
||||
"dataclass_transform",
|
||||
];
|
||||
|
||||
struct ImportReplacer<'a> {
|
||||
|
@ -369,6 +376,9 @@ impl<'a> ImportReplacer<'a> {
|
|||
if self.version >= PythonVersion::Py311 {
|
||||
typing_extensions_to_typing.extend(TYPING_EXTENSIONS_TO_TYPING_311);
|
||||
}
|
||||
if self.version >= PythonVersion::Py312 {
|
||||
typing_extensions_to_typing.extend(TYPING_EXTENSIONS_TO_TYPING_312);
|
||||
}
|
||||
if let Some(operation) = self.try_replace(&typing_extensions_to_typing, "typing") {
|
||||
operations.push(operation);
|
||||
}
|
||||
|
|
|
@ -433,7 +433,7 @@ pub struct Options {
|
|||
pub namespace_packages: Option<Vec<String>>,
|
||||
#[option(
|
||||
default = r#""py310""#,
|
||||
value_type = r#""py37" | "py38" | "py39" | "py310" | "py311""#,
|
||||
value_type = r#""py37" | "py38" | "py39" | "py310" | "py311" | "py312""#,
|
||||
example = r#"
|
||||
# Always generate Python 3.7-compatible code.
|
||||
target-version = "py37"
|
||||
|
|
|
@ -30,6 +30,7 @@ pub enum PythonVersion {
|
|||
Py39,
|
||||
Py310,
|
||||
Py311,
|
||||
Py312,
|
||||
}
|
||||
|
||||
impl From<PythonVersion> for Pep440Version {
|
||||
|
@ -47,6 +48,7 @@ impl PythonVersion {
|
|||
Self::Py39 => (3, 9),
|
||||
Self::Py310 => (3, 10),
|
||||
Self::Py311 => (3, 11),
|
||||
Self::Py312 => (3, 12),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ Options:
|
|||
-o, --output-file <OUTPUT_FILE>
|
||||
Specify file to write the linter output to (default: stdout)
|
||||
--target-version <TARGET_VERSION>
|
||||
The minimum Python version that should be supported [possible values: py37, py38, py39, py310, py311]
|
||||
The minimum Python version that should be supported [possible values: py37, py38, py39, py310, py311, py312]
|
||||
--config <CONFIG>
|
||||
Path to the `pyproject.toml` or `ruff.toml` file to use for configuration
|
||||
--statistics
|
||||
|
|
3
ruff.schema.json
generated
3
ruff.schema.json
generated
|
@ -1555,7 +1555,8 @@
|
|||
"py38",
|
||||
"py39",
|
||||
"py310",
|
||||
"py311"
|
||||
"py311",
|
||||
"py312"
|
||||
]
|
||||
},
|
||||
"Quote": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue