Skip to content

Commit

Permalink
Flag deprecated (but renamed) imports in UP035
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Mar 11, 2023
1 parent 841bcf1 commit 3e6d8ae
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 105 deletions.
2 changes: 1 addition & 1 deletion crates/ruff/resources/test/fixtures/pyupgrade/UP035.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
Good,
)

from typing import Callable, Match, Pattern, List, OrderedDict
from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet

if True: from collections import (
Mapping, Counter)
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,8 @@ where
if self.settings.rules.enabled(&Rule::RewriteCElementTree) {
pyupgrade::rules::replace_c_element_tree(self, stmt);
}
if self.settings.rules.enabled(&Rule::ImportReplacements) {
pyupgrade::rules::import_replacements(
if self.settings.rules.enabled(&Rule::DeprecatedImport) {
pyupgrade::rules::deprecated_import(
self,
stmt,
names,
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<Rule> {
(Pyupgrade, "032") => Rule::FString,
(Pyupgrade, "033") => Rule::FunctoolsCache,
(Pyupgrade, "034") => Rule::ExtraneousParentheses,
(Pyupgrade, "035") => Rule::ImportReplacements,
(Pyupgrade, "035") => Rule::DeprecatedImport,
(Pyupgrade, "036") => Rule::OutdatedVersionBlock,
(Pyupgrade, "037") => Rule::QuotedAnnotation,
(Pyupgrade, "038") => Rule::IsinstanceWithTuple,
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ ruff_macros::register_rules!(
rules::pyupgrade::rules::FString,
rules::pyupgrade::rules::FunctoolsCache,
rules::pyupgrade::rules::ExtraneousParentheses,
rules::pyupgrade::rules::ImportReplacements,
rules::pyupgrade::rules::DeprecatedImport,
rules::pyupgrade::rules::OutdatedVersionBlock,
rules::pyupgrade::rules::QuotedAnnotation,
rules::pyupgrade::rules::IsinstanceWithTuple,
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/rules/pyupgrade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod tests {
#[test_case(Rule::FString, Path::new("UP032.py"); "UP032")]
#[test_case(Rule::FunctoolsCache, Path::new("UP033.py"); "UP033")]
#[test_case(Rule::ExtraneousParentheses, Path::new("UP034.py"); "UP034")]
#[test_case(Rule::ImportReplacements, Path::new("UP035.py"); "UP035")]
#[test_case(Rule::DeprecatedImport, Path::new("UP035.py"); "UP035")]
#[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_0.py"); "UP036_0")]
#[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_1.py"); "UP036_1")]
#[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_2.py"); "UP036_2")]
Expand Down
Loading

0 comments on commit 3e6d8ae

Please sign in to comment.