summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDani Alcala <112832187+clavedeluna@users.noreply.github.com>2022-11-22 17:41:05 -0300
committerGitHub <noreply@github.com>2022-11-22 20:41:05 +0000
commit0a6b1828685957dc27e9d9a1f3d708a20d6f2b35 (patch)
treeddabd2db83886ebfcd79a8c61603deeca6d3986e
parent0c947a00c7c14bfe476e96b560d0ae54247a5977 (diff)
downloadpylint-git-0a6b1828685957dc27e9d9a1f3d708a20d6f2b35.tar.gz
Create `TERMINATING_FUNCS_QNAMES` (#7825)
-rw-r--r--pylint/checkers/utils.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 8f1a39da5..a2a0c1b37 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -233,6 +233,10 @@ SUBSCRIPTABLE_CLASSES_PEP585 = frozenset(
SINGLETON_VALUES = {True, False, None}
+TERMINATING_FUNCS_QNAMES = frozenset(
+ {"_sitebuiltins.Quitter", "sys.exit", "posix._exit", "nt._exit"}
+)
+
class NoSuchArgumentError(Exception):
pass
@@ -2149,11 +2153,12 @@ def is_terminating_func(node: nodes.Call) -> bool:
):
return False
- qnames = {"_sitebuiltins.Quitter", "sys.exit", "posix._exit", "nt._exit"}
-
try:
for inferred in node.func.infer():
- if hasattr(inferred, "qname") and inferred.qname() in qnames:
+ if (
+ hasattr(inferred, "qname")
+ and inferred.qname() in TERMINATING_FUNCS_QNAMES
+ ):
return True
except (StopIteration, astroid.InferenceError):
pass