Skip to content

Commit 86a2eba

Browse files
authored
[pyupgrade] Stop recommending removed typing.no_type_check_decorator (UP035) (#28475)
Summary -- This PR removes `typing_extensions.no_type_check_decorator` from the list of moved members in UP035. As the [docs](https://docs.python.org/3/library/typing.html#typing.no_type_check_decorator) indicate, this decorator has been deprecated since 3.13 and is removed in 3.15, so the rule should just leave it alone. The change is not version-gated because it seemed weird to me to recommend making this change with a target version of 3.12, for example, only for the user to have to change it back when they eventually bump their Python version. I initially thought that `typing_extensions` would continue to backport this, but it appears that they removed it as well: python/typing_extensions#723. I don't think that actually changes how we should handle it, though. Test Plan -- Added a couple of tests showing no diagnostic
1 parent 609e184 commit 86a2eba

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎crates/ruff_linter/resources/test/fixtures/pyupgrade/UP035.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,7 @@
132132

133133
# UP035 on py37+ only
134134
from typing.re import Pattern
135+
136+
# `no_type_check_decorator` was removed from `typing` in Python 3.15.
137+
from typing_extensions import no_type_check_decorator
138+
from typing_extensions import no_type_check, no_type_check_decorator

‎crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ const TYPING_EXTENSIONS_TO_TYPING: &[&str] = &[
193193
"ValuesView",
194194
"cast",
195195
"no_type_check",
196-
"no_type_check_decorator",
197196
// Introduced in Python 3.5.2, but `typing_extensions` contains backported bugfixes and
198197
// optimizations,
199198
// "NewType",

‎crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,9 +1130,28 @@ UP035 [*] Import from `re` instead: `Pattern`
11301130
133 | # UP035 on py37+ only
11311131
134 | from typing.re import Pattern
11321132
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1133+
135 |
1134+
136 | # `no_type_check_decorator` was removed from `typing` in Python 3.15.
1135+
|
11331136
help: Import from `re`
11341137
|
11351138
133 | # UP035 on py37+ only
11361139
- from typing.re import Pattern
11371140
134 + from re import Pattern
1141+
135 |
1142+
|
1143+
1144+
UP035 [*] Import from `typing` instead: `no_type_check`
1145+
--> UP035.py:138:1
1146+
|
1147+
136 | # `no_type_check_decorator` was removed from `typing` in Python 3.15.
1148+
137 | from typing_extensions import no_type_check_decorator
1149+
138 | from typing_extensions import no_type_check, no_type_check_decorator
1150+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1151+
help: Import from `typing`
1152+
|
1153+
137 | from typing_extensions import no_type_check_decorator
1154+
- from typing_extensions import no_type_check, no_type_check_decorator
1155+
138 + from typing_extensions import no_type_check_decorator
1156+
139 + from typing import no_type_check
11381157
|

0 commit comments

Comments
 (0)