From 7db6a2d6d4ebd474276d877d0c86646da45eb577 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 11 Feb 2023 07:50:56 +0100 Subject: [PATCH] Rename rules containing PEP reference in name --- README.md | 6 ++--- crates/ruff/src/checkers/ast.rs | 6 ++--- crates/ruff/src/checkers/physical_lines.rs | 8 ++----- crates/ruff/src/registry.rs | 8 +++---- crates/ruff/src/rules/pyupgrade/mod.rs | 22 +++++++++---------- crates/ruff/src/rules/pyupgrade/rules/mod.rs | 8 +++---- .../rules/unnecessary_coding_comment.rs | 7 +++--- .../pyupgrade/rules/use_pep585_annotation.rs | 11 +++++----- .../pyupgrade/rules/use_pep604_annotation.rs | 9 ++++---- ...ff__rules__pyupgrade__tests__UP006.py.snap | 8 +++---- ...ff__rules__pyupgrade__tests__UP007.py.snap | 14 ++++++------ ...__rules__pyupgrade__tests__UP009_0.py.snap | 2 +- ...__rules__pyupgrade__tests__UP009_1.py.snap | 2 +- ...tests__future_annotations_pep_585_p37.snap | 4 ++-- ...sts__future_annotations_pep_585_py310.snap | 10 ++++----- ...tests__future_annotations_pep_604_p37.snap | 4 ++-- ...sts__future_annotations_pep_604_py310.snap | 6 ++--- crates/ruff/src/rules/ruff/mod.rs | 2 +- 18 files changed, 67 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 0e10432300..5b5a2f4442 100644 --- a/README.md +++ b/README.md @@ -845,10 +845,10 @@ For more, see [pyupgrade](https://pypi.org/project/pyupgrade/) on PyPI. | UP003 | type-of-primitive | Use `{}` instead of `type(...)` | 🛠 | | UP004 | useless-object-inheritance | Class `{name}` inherits from `object` | 🛠 | | UP005 | deprecated-unittest-alias | `{alias}` is deprecated, use `{target}` | 🛠 | -| UP006 | use-pep585-annotation | Use `{}` instead of `{}` for type annotations | 🛠 | -| UP007 | use-pep604-annotation | Use `X \| Y` for type annotations | 🛠 | +| UP006 | deprecated-collection-type | Use `{}` instead of `{}` for type annotations | 🛠 | +| UP007 | typing-union | Use `X \| Y` for type annotations | 🛠 | | UP008 | super-call-with-parameters | Use `super()` instead of `super(__class__, self)` | 🛠 | -| UP009 | pep3120-unnecessary-coding-comment | UTF-8 encoding declaration is unnecessary | 🛠 | +| UP009 | utf8-encoding-declaration | UTF-8 encoding declaration is unnecessary | 🛠 | | UP010 | unnecessary-future-import | Unnecessary `__future__` import `{import}` for target Python version | 🛠 | | UP011 | lru-cache-without-parameters | Unnecessary parameters to `functools.lru_cache` | 🛠 | | UP012 | unnecessary-encode-utf8 | Unnecessary call to `encode` as UTF-8 | 🛠 | diff --git a/crates/ruff/src/checkers/ast.rs b/crates/ruff/src/checkers/ast.rs index 55b9c91be2..2fa6810714 100644 --- a/crates/ruff/src/checkers/ast.rs +++ b/crates/ruff/src/checkers/ast.rs @@ -2062,7 +2062,7 @@ where // Ex) Optional[...] if !self.in_deferred_string_type_definition && !self.settings.pyupgrade.keep_runtime_typing - && self.settings.rules.enabled(&Rule::UsePEP604Annotation) + && self.settings.rules.enabled(&Rule::TypingUnion) && (self.settings.target_version >= PythonVersion::Py310 || (self.settings.target_version >= PythonVersion::Py37 && self.annotations_future_enabled @@ -2117,7 +2117,7 @@ where // Ex) List[...] if !self.in_deferred_string_type_definition && !self.settings.pyupgrade.keep_runtime_typing - && self.settings.rules.enabled(&Rule::UsePEP585Annotation) + && self.settings.rules.enabled(&Rule::DeprecatedCollectionType) && (self.settings.target_version >= PythonVersion::Py39 || (self.settings.target_version >= PythonVersion::Py37 && self.annotations_future_enabled @@ -2162,7 +2162,7 @@ where // Ex) typing.List[...] if !self.in_deferred_string_type_definition && !self.settings.pyupgrade.keep_runtime_typing - && self.settings.rules.enabled(&Rule::UsePEP585Annotation) + && self.settings.rules.enabled(&Rule::DeprecatedCollectionType) && (self.settings.target_version >= PythonVersion::Py39 || (self.settings.target_version >= PythonVersion::Py37 && self.annotations_future_enabled diff --git a/crates/ruff/src/checkers/physical_lines.rs b/crates/ruff/src/checkers/physical_lines.rs index 541b1ae449..f141ad9e8d 100644 --- a/crates/ruff/src/checkers/physical_lines.rs +++ b/crates/ruff/src/checkers/physical_lines.rs @@ -38,16 +38,12 @@ pub fn check_physical_lines( let enforce_doc_line_too_long = settings.rules.enabled(&Rule::DocLineTooLong); let enforce_line_too_long = settings.rules.enabled(&Rule::LineTooLong); let enforce_no_newline_at_end_of_file = settings.rules.enabled(&Rule::NoNewLineAtEndOfFile); - let enforce_unnecessary_coding_comment = settings - .rules - .enabled(&Rule::PEP3120UnnecessaryCodingComment); + let enforce_unnecessary_coding_comment = settings.rules.enabled(&Rule::UTF8EncodingDeclaration); let enforce_mixed_spaces_and_tabs = settings.rules.enabled(&Rule::MixedSpacesAndTabs); let enforce_bidirectional_unicode = settings.rules.enabled(&Rule::BidirectionalUnicode); let fix_unnecessary_coding_comment = matches!(autofix, flags::Autofix::Enabled) - && settings - .rules - .should_fix(&Rule::PEP3120UnnecessaryCodingComment); + && settings.rules.should_fix(&Rule::UTF8EncodingDeclaration); let fix_shebang_whitespace = matches!(autofix, flags::Autofix::Enabled) && settings.rules.should_fix(&Rule::ShebangWhitespace); diff --git a/crates/ruff/src/registry.rs b/crates/ruff/src/registry.rs index d08458ed0d..2b677c9661 100644 --- a/crates/ruff/src/registry.rs +++ b/crates/ruff/src/registry.rs @@ -282,10 +282,10 @@ ruff_macros::define_rule_mapping!( UP003 => rules::pyupgrade::rules::TypeOfPrimitive, UP004 => rules::pyupgrade::rules::UselessObjectInheritance, UP005 => rules::pyupgrade::rules::DeprecatedUnittestAlias, - UP006 => rules::pyupgrade::rules::UsePEP585Annotation, - UP007 => rules::pyupgrade::rules::UsePEP604Annotation, + UP006 => rules::pyupgrade::rules::DeprecatedCollectionType, + UP007 => rules::pyupgrade::rules::TypingUnion, UP008 => rules::pyupgrade::rules::SuperCallWithParameters, - UP009 => rules::pyupgrade::rules::PEP3120UnnecessaryCodingComment, + UP009 => rules::pyupgrade::rules::UTF8EncodingDeclaration, UP010 => rules::pyupgrade::rules::UnnecessaryFutureImport, UP011 => rules::pyupgrade::rules::LRUCacheWithoutParameters, UP012 => rules::pyupgrade::rules::UnnecessaryEncodeUTF8, @@ -751,7 +751,7 @@ impl Rule { | Rule::LineTooLong | Rule::MixedSpacesAndTabs | Rule::NoNewLineAtEndOfFile - | Rule::PEP3120UnnecessaryCodingComment + | Rule::UTF8EncodingDeclaration | Rule::ShebangMissingExecutableFile | Rule::ShebangNotExecutable | Rule::ShebangNewline diff --git a/crates/ruff/src/rules/pyupgrade/mod.rs b/crates/ruff/src/rules/pyupgrade/mod.rs index c6c58a3e42..84446e609e 100644 --- a/crates/ruff/src/rules/pyupgrade/mod.rs +++ b/crates/ruff/src/rules/pyupgrade/mod.rs @@ -21,14 +21,14 @@ mod tests { #[test_case(Rule::TypeOfPrimitive, Path::new("UP003.py"); "UP003")] #[test_case(Rule::UselessObjectInheritance, Path::new("UP004.py"); "UP004")] #[test_case(Rule::DeprecatedUnittestAlias, Path::new("UP005.py"); "UP005")] - #[test_case(Rule::UsePEP585Annotation, Path::new("UP006.py"); "UP006")] - #[test_case(Rule::UsePEP604Annotation, Path::new("UP007.py"); "UP007")] + #[test_case(Rule::DeprecatedCollectionType, Path::new("UP006.py"); "UP006")] + #[test_case(Rule::TypingUnion, Path::new("UP007.py"); "UP007")] #[test_case(Rule::SuperCallWithParameters, Path::new("UP008.py"); "UP008")] - #[test_case(Rule::PEP3120UnnecessaryCodingComment, Path::new("UP009_0.py"); "UP009_0")] - #[test_case(Rule::PEP3120UnnecessaryCodingComment, Path::new("UP009_1.py"); "UP009_1")] - #[test_case(Rule::PEP3120UnnecessaryCodingComment, Path::new("UP009_2.py"); "UP009_2")] - #[test_case(Rule::PEP3120UnnecessaryCodingComment, Path::new("UP009_3.py"); "UP009_3")] - #[test_case(Rule::PEP3120UnnecessaryCodingComment, Path::new("UP009_4.py"); "UP009_4")] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_0.py"); "UP009_0")] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_1.py"); "UP009_1")] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_2.py"); "UP009_2")] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_3.py"); "UP009_3")] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_4.py"); "UP009_4")] #[test_case(Rule::UnnecessaryFutureImport, Path::new("UP010.py"); "UP010")] #[test_case(Rule::LRUCacheWithoutParameters, Path::new("UP011.py"); "UP011")] #[test_case(Rule::UnnecessaryEncodeUTF8, Path::new("UP012.py"); "UP012")] @@ -81,7 +81,7 @@ mod tests { Path::new("pyupgrade/future_annotations.py"), &settings::Settings { target_version: PythonVersion::Py37, - ..settings::Settings::for_rule(Rule::UsePEP585Annotation) + ..settings::Settings::for_rule(Rule::DeprecatedCollectionType) }, )?; assert_yaml_snapshot!(diagnostics); @@ -94,7 +94,7 @@ mod tests { Path::new("pyupgrade/future_annotations.py"), &settings::Settings { target_version: PythonVersion::Py310, - ..settings::Settings::for_rule(Rule::UsePEP585Annotation) + ..settings::Settings::for_rule(Rule::DeprecatedCollectionType) }, )?; assert_yaml_snapshot!(diagnostics); @@ -107,7 +107,7 @@ mod tests { Path::new("pyupgrade/future_annotations.py"), &settings::Settings { target_version: PythonVersion::Py37, - ..settings::Settings::for_rule(Rule::UsePEP604Annotation) + ..settings::Settings::for_rule(Rule::TypingUnion) }, )?; assert_yaml_snapshot!(diagnostics); @@ -120,7 +120,7 @@ mod tests { Path::new("pyupgrade/future_annotations.py"), &settings::Settings { target_version: PythonVersion::Py310, - ..settings::Settings::for_rule(Rule::UsePEP604Annotation) + ..settings::Settings::for_rule(Rule::TypingUnion) }, )?; assert_yaml_snapshot!(diagnostics); diff --git a/crates/ruff/src/rules/pyupgrade/rules/mod.rs b/crates/ruff/src/rules/pyupgrade/rules/mod.rs index ff7fb5cecc..081d8701a9 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/mod.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/mod.rs @@ -33,14 +33,12 @@ pub(crate) use super_call_with_parameters::{super_call_with_parameters, SuperCal pub(crate) use type_of_primitive::{type_of_primitive, TypeOfPrimitive}; pub(crate) use typing_text_str_alias::{typing_text_str_alias, TypingTextStrAlias}; pub(crate) use unnecessary_builtin_import::{unnecessary_builtin_import, UnnecessaryBuiltinImport}; -pub(crate) use unnecessary_coding_comment::{ - unnecessary_coding_comment, PEP3120UnnecessaryCodingComment, -}; +pub(crate) use unnecessary_coding_comment::{unnecessary_coding_comment, UTF8EncodingDeclaration}; pub(crate) use unnecessary_encode_utf8::{unnecessary_encode_utf8, UnnecessaryEncodeUTF8}; pub(crate) use unnecessary_future_import::{unnecessary_future_import, UnnecessaryFutureImport}; pub(crate) use unpack_list_comprehension::{unpack_list_comprehension, RewriteListComprehension}; -pub(crate) use use_pep585_annotation::{use_pep585_annotation, UsePEP585Annotation}; -pub(crate) use use_pep604_annotation::{use_pep604_annotation, UsePEP604Annotation}; +pub(crate) use use_pep585_annotation::{use_pep585_annotation, DeprecatedCollectionType}; +pub(crate) use use_pep604_annotation::{use_pep604_annotation, TypingUnion}; pub(crate) use useless_metaclass_type::{useless_metaclass_type, UselessMetaclassType}; pub(crate) use useless_object_inheritance::{useless_object_inheritance, UselessObjectInheritance}; diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs index eccdd37235..fe3d2ff864 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs @@ -9,9 +9,10 @@ use crate::registry::Diagnostic; use crate::violation::AlwaysAutofixableViolation; define_violation!( - pub struct PEP3120UnnecessaryCodingComment; + // TODO: document referencing [PEP 3120]: https://peps.python.org/pep-3120/ + pub struct UTF8EncodingDeclaration; ); -impl AlwaysAutofixableViolation for PEP3120UnnecessaryCodingComment { +impl AlwaysAutofixableViolation for UTF8EncodingDeclaration { #[derive_message_formats] fn message(&self) -> String { format!("UTF-8 encoding declaration is unnecessary") @@ -31,7 +32,7 @@ pub fn unnecessary_coding_comment(lineno: usize, line: &str, autofix: bool) -> O // PEP3120 makes utf-8 the default encoding. if CODING_COMMENT_REGEX.is_match(line) { let mut diagnostic = Diagnostic::new( - PEP3120UnnecessaryCodingComment, + UTF8EncodingDeclaration, Range::new(Location::new(lineno + 1, 0), Location::new(lineno + 2, 0)), ); if autofix { diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs b/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs index b3dbeefc7d..052389858e 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs @@ -8,14 +8,15 @@ use crate::registry::Diagnostic; use crate::violation::AlwaysAutofixableViolation; define_violation!( - pub struct UsePEP585Annotation { + // TODO: document referencing [PEP 585]: https://peps.python.org/pep-0585/ + pub struct DeprecatedCollectionType { pub name: String, } ); -impl AlwaysAutofixableViolation for UsePEP585Annotation { +impl AlwaysAutofixableViolation for DeprecatedCollectionType { #[derive_message_formats] fn message(&self) -> String { - let UsePEP585Annotation { name } = self; + let DeprecatedCollectionType { name } = self; format!( "Use `{}` instead of `{}` for type annotations", name.to_lowercase(), @@ -24,7 +25,7 @@ impl AlwaysAutofixableViolation for UsePEP585Annotation { } fn autofix_title(&self) -> String { - let UsePEP585Annotation { name } = self; + let DeprecatedCollectionType { name } = self; format!("Replace `{name}` with `{}`", name.to_lowercase(),) } } @@ -36,7 +37,7 @@ pub fn use_pep585_annotation(checker: &mut Checker, expr: &Expr) { .and_then(|call_path| call_path.last().copied()) { let mut diagnostic = Diagnostic::new( - UsePEP585Annotation { + DeprecatedCollectionType { name: binding.to_string(), }, Range::from_located(expr), diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs b/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs index d4453afb97..3d709810ef 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs @@ -9,9 +9,10 @@ use crate::registry::Diagnostic; use crate::violation::AlwaysAutofixableViolation; define_violation!( - pub struct UsePEP604Annotation; + // TODO: document referencing [PEP 604]: https://peps.python.org/pep-0604/ + pub struct TypingUnion; ); -impl AlwaysAutofixableViolation for UsePEP604Annotation { +impl AlwaysAutofixableViolation for TypingUnion { #[derive_message_formats] fn message(&self) -> String { format!("Use `X | Y` for type annotations") @@ -95,7 +96,7 @@ pub fn use_pep604_annotation(checker: &mut Checker, expr: &Expr, value: &Expr, s match typing_member { TypingMember::Optional => { - let mut diagnostic = Diagnostic::new(UsePEP604Annotation, Range::from_located(expr)); + let mut diagnostic = Diagnostic::new(TypingUnion, Range::from_located(expr)); if checker.patch(diagnostic.kind.rule()) { diagnostic.amend(Fix::replacement( unparse_expr(&optional(slice), checker.stylist), @@ -106,7 +107,7 @@ pub fn use_pep604_annotation(checker: &mut Checker, expr: &Expr, value: &Expr, s checker.diagnostics.push(diagnostic); } TypingMember::Union => { - let mut diagnostic = Diagnostic::new(UsePEP604Annotation, Range::from_located(expr)); + let mut diagnostic = Diagnostic::new(TypingUnion, Range::from_located(expr)); if checker.patch(diagnostic.kind.rule()) { match &slice.node { ExprKind::Slice { .. } => { diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006.py.snap index eb2f84a19b..0e8e08a9d1 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 4 @@ -22,7 +22,7 @@ expression: diagnostics column: 20 parent: ~ - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 11 @@ -41,7 +41,7 @@ expression: diagnostics column: 13 parent: ~ - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 18 @@ -60,7 +60,7 @@ expression: diagnostics column: 15 parent: ~ - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 25 diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap index 1f33d69538..2940435638 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 6 column: 9 @@ -21,7 +21,7 @@ expression: diagnostics column: 22 parent: ~ - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 10 column: 9 @@ -39,7 +39,7 @@ expression: diagnostics column: 29 parent: ~ - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 14 column: 9 @@ -57,7 +57,7 @@ expression: diagnostics column: 45 parent: ~ - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 14 column: 25 @@ -75,7 +75,7 @@ expression: diagnostics column: 44 parent: ~ - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 18 column: 9 @@ -93,7 +93,7 @@ expression: diagnostics column: 31 parent: ~ - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 22 column: 9 @@ -111,7 +111,7 @@ expression: diagnostics column: 33 parent: ~ - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 26 column: 9 diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_0.py.snap index 1ece4ed76e..8d4f041823 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_0.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_0.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - PEP3120UnnecessaryCodingComment: ~ + UTF8EncodingDeclaration: ~ location: row: 1 column: 0 diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_1.py.snap index 9baa8ae101..737305d515 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_1.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_1.py.snap @@ -3,7 +3,7 @@ source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - PEP3120UnnecessaryCodingComment: ~ + UTF8EncodingDeclaration: ~ location: row: 2 column: 0 diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap index 74a6757129..c8f42f7aa0 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap @@ -1,9 +1,9 @@ --- -source: src/rules/pyupgrade/mod.rs +source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 34 diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap index 130bb0fc2d..daaf2ac849 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap @@ -1,9 +1,9 @@ --- -source: src/rules/pyupgrade/mod.rs +source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 34 @@ -22,7 +22,7 @@ expression: diagnostics column: 21 parent: ~ - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 35 @@ -41,7 +41,7 @@ expression: diagnostics column: 12 parent: ~ - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 42 @@ -60,7 +60,7 @@ expression: diagnostics column: 30 parent: ~ - kind: - UsePEP585Annotation: + DeprecatedCollectionType: name: List location: row: 42 diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap index fa02dfac09..0d84122c99 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap @@ -1,9 +1,9 @@ --- -source: src/rules/pyupgrade/mod.rs +source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 40 column: 3 diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap index 927b02d663..ae49de6334 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap @@ -1,9 +1,9 @@ --- -source: src/rules/pyupgrade/mod.rs +source: crates/ruff/src/rules/pyupgrade/mod.rs expression: diagnostics --- - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 40 column: 3 @@ -21,7 +21,7 @@ expression: diagnostics column: 16 parent: ~ - kind: - UsePEP604Annotation: ~ + TypingUnion: ~ location: row: 42 column: 20 diff --git a/crates/ruff/src/rules/ruff/mod.rs b/crates/ruff/src/rules/ruff/mod.rs index e10319737c..d654d07454 100644 --- a/crates/ruff/src/rules/ruff/mod.rs +++ b/crates/ruff/src/rules/ruff/mod.rs @@ -111,7 +111,7 @@ mod tests { fn redirects() -> Result<()> { let diagnostics = test_path( Path::new("ruff/redirects.py"), - &settings::Settings::for_rules(vec![Rule::UsePEP604Annotation]), + &settings::Settings::for_rules(vec![Rule::TypingUnion]), )?; assert_yaml_snapshot!(diagnostics); Ok(())