summaryrefslogtreecommitdiff
path: root/pylint/checkers/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/checkers/base.py')
-rw-r--r--pylint/checkers/base.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 9d61cf10f..46eb0d17d 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -2511,14 +2511,18 @@ class ComparisonChecker(_BasicChecker):
left_operand, right_operand = node.left, node.ops[0][1]
# this message should be emitted only when there is comparison of bare callable
# with non bare callable.
- if (
- sum(
- 1
- for operand in (left_operand, right_operand)
- if isinstance(utils.safe_infer(operand), bare_callables)
- )
- == 1
- ):
+ number_of_bare_callables = 0
+ for operand in left_operand, right_operand:
+ inferred = utils.safe_infer(operand)
+ # Ignore callables that raise, as well as typing constants
+ # implemented as functions (that raise via their decorator)
+ if (
+ isinstance(inferred, bare_callables)
+ and "typing._SpecialForm" not in inferred.decoratornames()
+ and not any(isinstance(x, nodes.Raise) for x in inferred.body)
+ ):
+ number_of_bare_callables += 1
+ if number_of_bare_callables == 1:
self.add_message("comparison-with-callable", node=node)
@utils.check_messages(