MartinThoma / flake8-simplify

❄ A flake8 plugin that helps you to simplify code
MIT License
185 stars 19 forks source link

[Adjust Rule] SIM111: Fix all(not el for el in it) #38

Closed MartinThoma closed 3 years ago

MartinThoma commented 3 years ago

Desired change

Explanation

The current recommended change is wrong.

Example

This is an example where the mentioned rule(s) would currently be suboptimal:

# Original
for interval in self.intervals:
    if not interval.is_empty():
        return False
return True

# Current replacement
return all(not interval.is_empty() for interval in self.intervals)

# Correct
return all(interval.is_empty() for interval in self.intervals)