Skip to content

flake8 compare and membership

Wout De Nolf requested to merge flake8_compare_and_membership into master
28    E711 comparison to None should be 'if cond is None:'
66    E712 comparison to False should be 'if cond is False:' or 'if not cond:'
20    E713 test for membership should be 'not in'
2     E714 test for object identity should be 'is not'
2     E721 do not compare types, use 'isinstance()'
5     F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)

I was conservative with E712. I replaced x == False with x is False if I was not absolutely sure x was a boolean and the context indicates that we also need to check that it's a boolean (could be None or Null or ...). Otherwise I replaced x == False with not x. Same logic for True.

Edited by Wout De Nolf

Merge request reports