[Libguestfs] [PATCH libnbd] python: Make flake8 output more useful

Nir Soffer nirsof at gmail.com
Sun Apr 25 20:36:15 UTC 2021


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




More information about the Libguestfs mailing list