Skip to content

Commit

Permalink
Add last remaining deprecated typing imports (#3529)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Mar 15, 2023
1 parent 2545869 commit 57796c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 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, AbstractSet
from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager

if True: from collections import (
Mapping, Counter)
Expand Down
2 changes: 2 additions & 0 deletions crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ const TYPING_TO_RENAME_PY39: &[(&str, &str)] = &[
"AsyncContextManager",
"contextlib.AbstractAsyncContextManager",
),
("ContextManager", "contextlib.AbstractContextManager"),
("AbstractSet", "collections.abc.Set"),
("Tuple", "tuple"),
("List", "list"),
("FrozenSet", "frozenset"),
("Dict", "dict"),
("Type", "type"),
("Set", "set"),
("Deque", "collections.deque"),
("DefaultDict", "collections.defaultdict"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ expression: diagnostics
column: 0
end_location:
row: 44
column: 75
column: 91
fix:
content: "from typing import Match, Pattern, List, OrderedDict, AbstractSet\nfrom collections.abc import Callable"
content: "from typing import Match, Pattern, List, OrderedDict, AbstractSet, ContextManager\nfrom collections.abc import Callable"
location:
row: 44
column: 0
end_location:
row: 44
column: 75
column: 91
parent: ~
- kind:
name: DeprecatedImport
Expand All @@ -312,15 +312,15 @@ expression: diagnostics
column: 0
end_location:
row: 44
column: 75
column: 91
fix:
content: "from typing import Callable, Match, Pattern, List, AbstractSet\nfrom collections import OrderedDict"
content: "from typing import Callable, Match, Pattern, List, AbstractSet, ContextManager\nfrom collections import OrderedDict"
location:
row: 44
column: 0
end_location:
row: 44
column: 75
column: 91
parent: ~
- kind:
name: DeprecatedImport
Expand All @@ -332,15 +332,15 @@ expression: diagnostics
column: 0
end_location:
row: 44
column: 75
column: 91
fix:
content: "from typing import Callable, List, OrderedDict, AbstractSet\nfrom re import Match, Pattern"
content: "from typing import Callable, List, OrderedDict, AbstractSet, ContextManager\nfrom re import Match, Pattern"
location:
row: 44
column: 0
end_location:
row: 44
column: 75
column: 91
parent: ~
- kind:
name: DeprecatedImport
Expand All @@ -352,7 +352,7 @@ expression: diagnostics
column: 0
end_location:
row: 44
column: 75
column: 91
fix: ~
parent: ~
- kind:
Expand All @@ -365,7 +365,20 @@ expression: diagnostics
column: 0
end_location:
row: 44
column: 75
column: 91
fix: ~
parent: ~
- kind:
name: DeprecatedImport
body: "`typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead"
suggestion: ~
fixable: false
location:
row: 44
column: 0
end_location:
row: 44
column: 91
fix: ~
parent: ~
- kind:
Expand Down

0 comments on commit 57796c5

Please sign in to comment.