summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-04-11 15:24:33 +0200
committerGitHub <noreply@github.com>2021-04-11 15:24:33 +0200
commit5949e4805d932411985aeeb6e55b7c9be6ef2c21 (patch)
treecb784f00a45868c5952f662d3926ebf4945c7fb9
parent56db200f856a2d913ae4dc6316dce0013f853733 (diff)
downloadpylint-git-5949e4805d932411985aeeb6e55b7c9be6ef2c21.tar.gz
Small performance improvement (PEP 585 check) (#4335)
-rw-r--r--pylint/checkers/utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 059c1fe7f..ab6e3e96c 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -1341,7 +1341,10 @@ def is_class_subscriptable_pep585_with_postponed_evaluation_enabled(
"""Check if class is subscriptable with PEP 585 and
postponed evaluation enabled.
"""
- if not is_postponed_evaluation_enabled(node):
+ if (
+ not is_postponed_evaluation_enabled(node)
+ or value.qname() not in SUBSCRIPTABLE_CLASSES_PEP585
+ ):
return False
parent_node = node.parent
@@ -1354,9 +1357,7 @@ def is_class_subscriptable_pep585_with_postponed_evaluation_enabled(
parent_node = parent_node.parent
if isinstance(parent_node, astroid.Module):
return False
- if value.qname() in SUBSCRIPTABLE_CLASSES_PEP585:
- return True
- return False
+ return True
def is_subclass_of(child: astroid.ClassDef, parent: astroid.ClassDef) -> bool: