Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@

SINGLETON_VALUES = {True, False, None}

TERMINATING_FUNCS_QNAMES = frozenset(
{"_sitebuiltins.Quitter", "sys.exit", "posix._exit", "nt._exit"}
)


class NoSuchArgumentError(Exception):
pass
Expand Down Expand Up @@ -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
Expand Down