MartinThoma / flake8-simplify

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

SIM110: a false-positive test-case #148

Open marxin opened 2 years ago

marxin commented 2 years ago

Desired change

Example

def _check_libalternatives_presence(pkg, alts_requirement):
    for path in pkg.files:
        if path.startswith('/usr/share/libalternatives/'):
            return True
    return any(req[0] == alts_requirement for req in pkg.requires + pkg.prereq)
$ flake8 /tmp/snippet.py
/tmp/snippet.py:2:5: SIM110 Use 'return any(path.startswith('/usr/share/libalternatives/') for path in pkg.files)'

It's wrong as the last statement will be never executed.