Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add last remaining deprecated typing imports #3529

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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