Skip to content

Commit 0ef8a4c

Browse files
authored
Type _infer of BoolOp (#1658)
1 parent 49bf081 commit 0ef8a4c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

astroid/inference.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ def infer_subscript(self, context=None):
451451

452452
@decorators.raise_if_nothing_inferred
453453
@decorators.path_wrapper
454-
def _infer_boolop(self, context=None):
454+
def _infer_boolop(
455+
self: nodes.BoolOp, context: InferenceContext | None = None, **kwargs: Any
456+
) -> Generator[InferenceResult, None, InferenceErrorInfo | None]:
455457
"""Infer a boolean operation (and / or / not).
456458
457459
The function will calculate the boolean operation
@@ -465,12 +467,12 @@ def _infer_boolop(self, context=None):
465467
predicate = operator.not_
466468

467469
try:
468-
values = [value.infer(context=context) for value in values]
470+
inferred_values = [value.infer(context=context) for value in values]
469471
except InferenceError:
470472
yield util.Uninferable
471473
return None
472474

473-
for pair in itertools.product(*values):
475+
for pair in itertools.product(*inferred_values):
474476
if any(item is util.Uninferable for item in pair):
475477
# Can't infer the final result, just yield Uninferable.
476478
yield util.Uninferable
@@ -499,10 +501,10 @@ def _infer_boolop(self, context=None):
499501
else:
500502
yield value
501503

502-
return dict(node=self, context=context)
504+
return InferenceErrorInfo(node=self, context=context)
503505

504506

505-
nodes.BoolOp._infer = _infer_boolop
507+
nodes.BoolOp._infer = _infer_boolop # type: ignore[assignment]
506508

507509

508510
# UnaryOp, BinOp and AugAssign inferences

0 commit comments

Comments
 (0)