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

[pyupgrade] Ignore is_typeddict and TypedDict for deprecated-import (UP035) #15800

Merged
merged 2 commits into from
Jan 29, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pyupgrade/UP035.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@

# UP035 on py313+ only
from typing_extensions import deprecated


# https://github.com/astral-sh/ruff/issues/15780
from typing_extensions import is_typeddict
# https://github.com/astral-sh/ruff/pull/15800#pullrequestreview-2580704217
from typing_extensions import TypedDict
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ const TYPING_EXTENSIONS_TO_TYPING_310: &[&str] = &[
"TypeGuard",
"get_args",
"get_origin",
"is_typeddict",
// Introduced in Python 3.10, but `typing_extensions` equivalent
// also checks for `typing_extensions.TypedDict` in addition to `typing.TypedDict`.
// "is_typeddict",
];

// Python 3.11+
Expand Down Expand Up @@ -382,13 +384,14 @@ const TYPING_EXTENSIONS_TO_TYPING_313: &[&str] = &[
// Introduced in Python 3.8, but typing_extensions
// backports features and bugfixes from py313:
"Protocol",
"TypedDict",
"runtime_checkable",
// Introduced in earlier Python versions,
// but typing_extensions backports PEP-696:
"ParamSpec",
"TypeVar",
"TypeVarTuple",
// `typing_extensions` backports PEP 728 (TypedDict with Typed Extra Items)
// "TypedDict",
];

// Members of `typing_extensions` that were moved to `types`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1188,3 +1188,6 @@ UP035.py:111:1: UP035 [*] Import from `warnings` instead: `deprecated`
110 110 | # UP035 on py313+ only
111 |-from typing_extensions import deprecated
111 |+from warnings import deprecated
112 112 |
113 113 |
114 114 | # https://github.com/astral-sh/ruff/issues/15780
Loading