From a94f88d113f68da9cad15b241dc1952801f36478 Mon Sep 17 00:00:00 2001 From: clavedeluna Date: Tue, 22 Nov 2022 16:09:28 -0300 Subject: [PATCH] create `TERMINATING_FUNCS_QNAMES` --- pylint/checkers/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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