Skip to content

Commit e72fe66

Browse files
authored
Remove utils.subscriptable_with_postponed_evaluation_enabled (#6607)
1 parent f6479fd commit e72fe66

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

ChangeLog

+2-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ Release date: TBA
314314
Closes #6597
315315

316316
* ``is_class_subscriptable_pep585_with_postponed_evaluation_enabled`` has been deprecated.
317-
Use ``subscriptable_with_postponed_evaluation_enabled`` instead.
317+
Use ``is_postponed_evaluation_enabled(node) and is_node_in_type_annotation_context(node)``
318+
instead.
318319

319320
Ref #6536
320321

doc/whatsnew/2.14.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ Other Changes
215215

216216
* The ``set_config_directly`` decorator has been removed.
217217

218-
219218
* Fix falsely issuing ``useless-suppression`` on the ``wrong-import-position`` checker.
220219

221220
Closes #5219
@@ -253,11 +252,6 @@ Other Changes
253252

254253
Closes #6597
255254

256-
* ``is_class_subscriptable_pep585_with_postponed_evaluation_enabled`` has been deprecated.
257-
Use ``subscriptable_with_postponed_evaluation_enabled`` instead.
258-
259-
Ref #6536
260-
261255
* The refactoring checker now also raises 'consider-using-a-generator' messages for
262256
``max()``, ``min()`` and ``sum()``.
263257

@@ -371,3 +365,9 @@ Deprecations
371365
be removed in a future release.
372366

373367
Ref #5392
368+
369+
* ``is_class_subscriptable_pep585_with_postponed_evaluation_enabled`` has been deprecated.
370+
Use ``is_postponed_evaluation_enabled(node) and is_node_in_type_annotation_context(node)``
371+
instead.
372+
373+
Ref #6536

pylint/checkers/utils.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,9 @@ def supports_getitem(value: nodes.NodeNG, node: nodes.NodeNG) -> bool:
12171217
if isinstance(value, nodes.ClassDef):
12181218
if _supports_protocol_method(value, CLASS_GETITEM_METHOD):
12191219
return True
1220-
if subscriptable_with_postponed_evaluation_enabled(node):
1220+
if is_postponed_evaluation_enabled(node) and is_node_in_type_annotation_context(
1221+
node
1222+
):
12211223
return True
12221224
return _supports_protocol(value, _supports_getitem_protocol)
12231225

@@ -1405,7 +1407,8 @@ def is_class_subscriptable_pep585_with_postponed_evaluation_enabled(
14051407
warnings.warn(
14061408
"'is_class_subscriptable_pep585_with_postponed_evaluation_enabled' has been "
14071409
"deprecated and will be removed in pylint 3.0. "
1408-
"Use 'subscriptable_with_postponed_evaluation_enabled' instead.",
1410+
"Use 'is_postponed_evaluation_enabled(node) and "
1411+
"is_node_in_type_annotation_context(node)' instead.",
14091412
DeprecationWarning,
14101413
)
14111414
return (
@@ -1415,13 +1418,6 @@ def is_class_subscriptable_pep585_with_postponed_evaluation_enabled(
14151418
)
14161419

14171420

1418-
def subscriptable_with_postponed_evaluation_enabled(node: nodes.NodeNG) -> bool:
1419-
"""Check if class can be subscriptable in type annotation context."""
1420-
return is_postponed_evaluation_enabled(node) and is_node_in_type_annotation_context(
1421-
node
1422-
)
1423-
1424-
14251421
def is_node_in_type_annotation_context(node: nodes.NodeNG) -> bool:
14261422
"""Check if node is in type annotation context.
14271423

0 commit comments

Comments
 (0)