diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 8f1a39da5c..a2a0c1b378 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -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 @@ -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