Skip to content

Commit

Permalink
avoid two iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Jun 10, 2022
1 parent bf7f322 commit cc90541
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pylint/checkers/base/basic_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,13 @@ def _check_using_constant_test(
elif isinstance(test, nodes.Call):
inferred_call = utils.safe_infer(test.func)
if isinstance(inferred_call, nodes.FunctionDef):
return_nodes = list(inferred_call._get_return_nodes_skip_functions())
if return_nodes and all(
isinstance(n.value, nodes.GeneratorExp) for n in return_nodes
):
all_returns_were_generator = None
for return_node in inferred_call._get_return_nodes_skip_functions():
if not isinstance(return_node.value, nodes.GeneratorExp):
all_returns_were_generator = False
break
all_returns_were_generator = True
if all_returns_were_generator:
self.add_message(
"using-constant-test", node=node, confidence=INFERENCE
)
Expand Down

0 comments on commit cc90541

Please sign in to comment.