Closed
Description
Current problem
def optimized_any_with_break(split_lines: list[str], max_chars: int) -> bool:
"""False negative found in https://github.com/PyCQA/pylint/pull/7697"""
potential_line_length_warning = False
for line in split_lines: # [consider-using-any-or-all]
if len(line) > max_chars:
potential_line_length_warning = True
break
return potential_line_length_warning
Can be simplified to
def optimized_any_with_break(split_lines: list[str], max_chars: int) -> bool:
return any(len(line) > max_chars for line in split_lines)
Desired solution
for-any-all
raised in this case.
Additional context
I did not think very hard about potential false positive, but I think it make sense to not raise if potential_line_length_warning
is not initialized directly above the for loop.