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

This commit is contained in:
InSync 2025-01-30 01:05:46 +07:00 committed by GitHub
parent 6c1e19592e
commit d151ca85d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -109,3 +109,9 @@ from typing_extensions import CapsuleType
# 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

View file

@ -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+
@ -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`.

View file

@ -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