mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
[pyupgrade
] Apply UP035
only on py313+ for get_type_hints()
(#18476)
This commit is contained in:
parent
8531f4b3ca
commit
33468cc8cc
3 changed files with 30 additions and 3 deletions
|
@ -110,6 +110,8 @@ from typing_extensions import CapsuleType
|
||||||
# UP035 on py313+ only
|
# UP035 on py313+ only
|
||||||
from typing_extensions import deprecated
|
from typing_extensions import deprecated
|
||||||
|
|
||||||
|
# UP035 on py313+ only
|
||||||
|
from typing_extensions import get_type_hints
|
||||||
|
|
||||||
# https://github.com/astral-sh/ruff/issues/15780
|
# https://github.com/astral-sh/ruff/issues/15780
|
||||||
from typing_extensions import is_typeddict
|
from typing_extensions import is_typeddict
|
||||||
|
|
|
@ -271,7 +271,7 @@ const TYPING_TO_RE_39: &[&str] = &["Match", "Pattern"];
|
||||||
const TYPING_RE_TO_RE_39: &[&str] = &["Match", "Pattern"];
|
const TYPING_RE_TO_RE_39: &[&str] = &["Match", "Pattern"];
|
||||||
|
|
||||||
// Members of `typing_extensions` that were moved to `typing`.
|
// Members of `typing_extensions` that were moved to `typing`.
|
||||||
const TYPING_EXTENSIONS_TO_TYPING_39: &[&str] = &["Annotated", "get_type_hints"];
|
const TYPING_EXTENSIONS_TO_TYPING_39: &[&str] = &["Annotated"];
|
||||||
|
|
||||||
// Members of `typing` that were moved _and_ renamed (and thus cannot be
|
// Members of `typing` that were moved _and_ renamed (and thus cannot be
|
||||||
// automatically fixed).
|
// automatically fixed).
|
||||||
|
@ -373,6 +373,9 @@ const TYPING_EXTENSIONS_TO_TYPING_313: &[&str] = &[
|
||||||
"NoDefault",
|
"NoDefault",
|
||||||
"ReadOnly",
|
"ReadOnly",
|
||||||
"TypeIs",
|
"TypeIs",
|
||||||
|
// Introduced in Python 3.5,
|
||||||
|
// but typing_extensions backports features from py313:
|
||||||
|
"get_type_hints",
|
||||||
// Introduced in Python 3.6,
|
// Introduced in Python 3.6,
|
||||||
// but typing_extensions backports features from py313:
|
// but typing_extensions backports features from py313:
|
||||||
"ContextManager",
|
"ContextManager",
|
||||||
|
|
|
@ -1179,6 +1179,8 @@ UP035.py:111:1: UP035 [*] Import from `warnings` instead: `deprecated`
|
||||||
110 | # UP035 on py313+ only
|
110 | # UP035 on py313+ only
|
||||||
111 | from typing_extensions import deprecated
|
111 | from typing_extensions import deprecated
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035
|
||||||
|
112 |
|
||||||
|
113 | # UP035 on py313+ only
|
||||||
|
|
|
|
||||||
= help: Import from `warnings`
|
= help: Import from `warnings`
|
||||||
|
|
||||||
|
@ -1189,5 +1191,25 @@ UP035.py:111:1: UP035 [*] Import from `warnings` instead: `deprecated`
|
||||||
111 |-from typing_extensions import deprecated
|
111 |-from typing_extensions import deprecated
|
||||||
111 |+from warnings import deprecated
|
111 |+from warnings import deprecated
|
||||||
112 112 |
|
112 112 |
|
||||||
113 113 |
|
113 113 | # UP035 on py313+ only
|
||||||
114 114 | # https://github.com/astral-sh/ruff/issues/15780
|
114 114 | from typing_extensions import get_type_hints
|
||||||
|
|
||||||
|
UP035.py:114:1: UP035 [*] Import from `typing` instead: `get_type_hints`
|
||||||
|
|
|
||||||
|
113 | # UP035 on py313+ only
|
||||||
|
114 | from typing_extensions import get_type_hints
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035
|
||||||
|
115 |
|
||||||
|
116 | # https://github.com/astral-sh/ruff/issues/15780
|
||||||
|
|
|
||||||
|
= help: Import from `typing`
|
||||||
|
|
||||||
|
ℹ Safe fix
|
||||||
|
111 111 | from typing_extensions import deprecated
|
||||||
|
112 112 |
|
||||||
|
113 113 | # UP035 on py313+ only
|
||||||
|
114 |-from typing_extensions import get_type_hints
|
||||||
|
114 |+from typing import get_type_hints
|
||||||
|
115 115 |
|
||||||
|
116 116 | # https://github.com/astral-sh/ruff/issues/15780
|
||||||
|
117 117 | from typing_extensions import is_typeddict
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue