Nir Soffer
2021-Apr-25 20:36 UTC
[Libguestfs] [PATCH libnbd] python: Make flake8 output more useful
Add .flake8 configuration file enabling show_source and statistics. This makes flake8 output more useful for handling bug reports like: https://gitlab.com/nbdkit/libnbd/-/issues/4 For example I added some bad changes: $ sh pycodestyle.sh ... python/nbdsh.py:20:1: F401 'unused' imported but unused import unused ^ python/nbdsh.py:22:1: E302 expected 2 blank lines, found 1 def bad_function(): ^ python/nbdsh.py:24:80: E501 line too long (87 > 79 characters) ? ? """ ? ? bad doctring. bad doctring. bad doctring. bad doctring. bad doctring. bad doctring. ? ? """ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^ /home/nsoffer/src/libnbd/python/nbdsh.py:28:1: E302 expected 2 blank lines, found 1 def shell(): ^ 2 ? ? E302 expected 2 blank lines, found 1 1 ? ? E501 line too long (87 > 79 characters) 1 ? ? F401 'unused' imported but unused Signed-off-by: Nir Soffer <nsoffer at redhat.com> --- python/.flake8 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 python/.flake8 diff --git a/python/.flake8 b/python/.flake8 new file mode 100644 index 0000000..0e1dec1 --- /dev/null +++ b/python/.flake8 @@ -0,0 +1,6 @@ +[flake8] +# Print the source code generating the error/warning in question. +show_source = True + +# Count the number of occurrences of each error/warning code and print a report. +statistics = True -- 2.26.3
Richard W.M. Jones
2021-Apr-26 07:26 UTC
[Libguestfs] [PATCH libnbd] python: Make flake8 output more useful
On Sun, Apr 25, 2021 at 11:36:15PM +0300, Nir Soffer wrote:> Add .flake8 configuration file enabling show_source and statistics. This > makes flake8 output more useful for handling bug reports like: > https://gitlab.com/nbdkit/libnbd/-/issues/4...> python/.flake8 | 6 ++++++I suspect this will be ignored if we're using srcdir != builddir (not that this works at the moment). The documentation is confusing about how exactly the file is found mentioning only the "project" directory whatever that means. https://flake8.pycqa.org/en/latest/user/configuration.html Should we add the equivalent command line parameters instead? Anyway, as it's only optional configuration, ACK. Rich.> 1 file changed, 6 insertions(+) > create mode 100644 python/.flake8 > > diff --git a/python/.flake8 b/python/.flake8 > new file mode 100644 > index 0000000..0e1dec1 > --- /dev/null > +++ b/python/.flake8 > @@ -0,0 +1,6 @@ > +[flake8] > +# Print the source code generating the error/warning in question. > +show_source = True > + > +# Count the number of occurrences of each error/warning code and print a report. > +statistics = True > -- > 2.26.3-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v