flake8-simplify icon indicating copy to clipboard operation
flake8-simplify copied to clipboard

SIM110: a false-positive test-case

Open marxin opened this issue 1 year ago • 0 comments

Desired change

  • Rule(s): SIM110
  • Adjustment: A false positive

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.

marxin avatar Jul 25 '22 19:07 marxin