Skip to content

Commit 0a6b182

Browse files
authored
Create TERMINATING_FUNCS_QNAMES (#7825)
1 parent 0c947a0 commit 0a6b182

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pylint/checkers/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@
233233

234234
SINGLETON_VALUES = {True, False, None}
235235

236+
TERMINATING_FUNCS_QNAMES = frozenset(
237+
{"_sitebuiltins.Quitter", "sys.exit", "posix._exit", "nt._exit"}
238+
)
239+
236240

237241
class NoSuchArgumentError(Exception):
238242
pass
@@ -2149,11 +2153,12 @@ def is_terminating_func(node: nodes.Call) -> bool:
21492153
):
21502154
return False
21512155

2152-
qnames = {"_sitebuiltins.Quitter", "sys.exit", "posix._exit", "nt._exit"}
2153-
21542156
try:
21552157
for inferred in node.func.infer():
2156-
if hasattr(inferred, "qname") and inferred.qname() in qnames:
2158+
if (
2159+
hasattr(inferred, "qname")
2160+
and inferred.qname() in TERMINATING_FUNCS_QNAMES
2161+
):
21572162
return True
21582163
except (StopIteration, astroid.InferenceError):
21592164
pass

0 commit comments

Comments
 (0)