Skip to content

Commit

Permalink
Add PythonVersion::Py312
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jun 22, 2023
1 parent 5f88ff8 commit deab3df
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/settings/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions crates/ruff/src/settings/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub enum PythonVersion {
Py39,
Py310,
Py311,
Py312,
}

impl From<PythonVersion> for Pep440Version {
Expand All @@ -47,6 +48,7 @@ impl PythonVersion {
Self::Py39 => (3, 9),
Self::Py310 => (3, 10),
Self::Py311 => (3, 11),
Self::Py312 => (3, 12),
}
}

Expand Down

0 comments on commit deab3df

Please sign in to comment.