Apply black and flake8 + add to ci
Common flake8 warnings
-
type(var) == int
is replacedisinstance(var, int)
and equivalent occurences - Bare excepts
except:
are replaced byexcept Exception:
because they capture SystemExit or CTRL-C (BaseException) and sometimes absorb it - Multi-lime imports are split. For example
import os, sys, unittest
- Variable is assigned but never used. For example
unused = myfunc(...)
becomes_ = myfunc(...)
or remove the call in case there are no side effects and it is not intended as a validation. - Module level import not at top of file.
- Module imported but unused.
-
not a in b
becomesa not in b
- A function
def run(beamline, **kwargs):
which does not use kwargs can be defined asdef run(beamline, **_):
-
unicode
isstr
but when used in combination withstr
(which used to bebytes
) you need to take care ofstr
andbytes
Edited by Wout De Nolf