Skip to content

Commit

Permalink
create TERMINATING_FUNCS_QNAMES
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Nov 22, 2022
1 parent 73dfd82 commit a94f88d
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit a94f88d

Please sign in to comment.