From c76ed1a69d238c155ee507566d2e7588212e1e55 Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Fri, 28 Oct 2022 23:35:18 +0200 Subject: [PATCH 1/4] Fix Flake8 error E741 ambiguous variable name --- lib/cfv/common.py | 34 +++++++++++++++++----------------- lib/cfv/osutil.py | 2 +- lib/cfv/strutil.py | 6 +++--- test/cfvtest.py | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/cfv/common.py b/lib/cfv/common.py index f284e19..3d871fa 100644 --- a/lib/cfv/common.py +++ b/lib/cfv/common.py @@ -724,10 +724,10 @@ class FooSum_Base(TextChksumType): def do_test_chksumfile_print_testingline(self, file): TextChksumType.do_test_chksumfile_print_testingline(self, file, parse_commentline(file.peekline(512), ';#')) - def do_test_chksumline(self, l): - if l[0] in ';#': + def do_test_chksumline(self, line): + if line[0] in ';#': return - x = self._foosum_rem.match(l) + x = self._foosum_rem.match(line) if not x: return -1 if x.group(2) == ' ': @@ -830,8 +830,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(r'MD5 \(.+\) = [0-9a-fA-F]{3 _bsdmd5rem = re.compile(r'MD5 \((.+)\) = ([0-9a-fA-F]{32})[\r\n]*$') - def do_test_chksumline(self, l): - x = self._bsdmd5rem.match(l) + def do_test_chksumline(self, line): + x = self._bsdmd5rem.match(line) if not x: return -1 self.test_file(x.group(1), strutil.unhexlify(x.group(2))) @@ -1332,10 +1332,10 @@ def do_test_chksumfile_print_testingline(self, file): # override the default testing line to show first SFV comment line, if any TextChksumType.do_test_chksumfile_print_testingline(self, file, parse_commentline(file.peekline(512), ';')) - def do_test_chksumline(self, l): - if l[0] == ';': + def do_test_chksumline(self, line): + if line[0] == ';': return - x = self._sfvrem.match(l) + x = self._sfvrem.match(line) if not x: return -1 self.test_file(x.group(1), strutil.unhexlify(x.group(2))) @@ -1437,8 +1437,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(_csvfnautore + '[0-9]+,[0-9a _csvrem = re.compile(_csvfnre + r'([0-9]+),([0-9a-fA-F]{8}),') - def do_test_chksumline(self, l): - x = self._csvrem.match(l) + def do_test_chksumline(self, line): + x = self._csvrem.match(line) if not x: return -1 self.test_file(csvunquote(x.group(1), x.group(2)), strutil.unhexlify(x.group(4)), int(x.group(3))) @@ -1469,8 +1469,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(r'%s[0-9]+,[0-9a-fA-F]{8},%s _csv4rem = re.compile(r'%s([0-9]+),([0-9a-fA-F]{8}),%s' % (_csvfnre, _csvstrre)) - def do_test_chksumline(self, l): - x = self._csv4rem.match(l) + def do_test_chksumline(self, line): + x = self._csv4rem.match(line) if not x: return -1 name = csvunquote(x.group(1), x.group(2)) @@ -1504,8 +1504,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(_csvfnautore + '[0-9]+,[\n\r _csv2rem = re.compile(_csvfnre + r'([0-9]+),') - def do_test_chksumline(self, l): - x = self._csv2rem.match(l) + def do_test_chksumline(self, line): + x = self._csv2rem.match(line) if not x: return -1 self.test_file(csvunquote(x.group(1), x.group(2)), None, int(x.group(3))) @@ -1581,11 +1581,11 @@ def do_test_chksumfile_print_testingline(self, file): _commentboundary = re.compile(r'^-+(\s+-+){1,4}\s*$') _nstrip = re.compile(r'[.,]') - def do_test_chksumline(self, l): - if self._commentboundary.match(l): + def do_test_chksumline(self, line): + if self._commentboundary.match(line): self.in_comments = not self.in_comments return - x = self._crcrem.match(l) + x = self._crcrem.match(line) if not x: if self.in_comments: return diff --git a/lib/cfv/osutil.py b/lib/cfv/osutil.py index f99b030..7255b7c 100644 --- a/lib/cfv/osutil.py +++ b/lib/cfv/osutil.py @@ -85,7 +85,7 @@ def path_split(filename): return parts -def strippath(filename, num='a', _splitdrivere=re.compile(r'[a-z]:[/\\]', re.I)): +def strippath(filename, num='a', _splitdrivere=re.compile(r'[a-z]:[/\\]', re.IGNORECASE)): """Strip off path components from the left side of the filename. >>> strippath(os.path.join('c:','foo','bar','baz')) diff --git a/lib/cfv/strutil.py b/lib/cfv/strutil.py index 13cbe3c..8eebaa3 100644 --- a/lib/cfv/strutil.py +++ b/lib/cfv/strutil.py @@ -6,17 +6,17 @@ from cfv import osutil -def safesort(l): +def safesort(seq): sl = [] ul = [] - for s in l: + for s in seq: if isinstance(s, str): sl.append(s) else: ul.append(s) sl.sort() ul.sort() - l[:] = ul + sl + seq[:] = ul + sl def showfn(s): diff --git a/test/cfvtest.py b/test/cfvtest.py index 874d082..3909cd6 100644 --- a/test/cfvtest.py +++ b/test/cfvtest.py @@ -52,7 +52,7 @@ def isatty(self): def write(self, s): pass - def writelines(self, l): + def writelines(self, lines): pass def flush(self): From e1580bf7f114bc12922cc249da37375961d24dbe Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Fri, 28 Oct 2022 23:38:33 +0200 Subject: [PATCH 2/4] Fix Flake8 error F401 'builtins.str' imported but unused --- lib/cfv/BitTorrent/bencode.py | 1 - lib/cfv/osutil.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib/cfv/BitTorrent/bencode.py b/lib/cfv/BitTorrent/bencode.py index 79dd01e..c247763 100644 --- a/lib/cfv/BitTorrent/bencode.py +++ b/lib/cfv/BitTorrent/bencode.py @@ -2,7 +2,6 @@ # see LICENSE.txt for license information from builtins import object -from builtins import str def decode_int(x, f): diff --git a/lib/cfv/osutil.py b/lib/cfv/osutil.py index 7255b7c..a6a3beb 100644 --- a/lib/cfv/osutil.py +++ b/lib/cfv/osutil.py @@ -1,5 +1,3 @@ -from builtins import str - import locale import os import re From d7864f75fa139babb823255756cce1ddf418c9a1 Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Fri, 28 Oct 2022 23:39:52 +0200 Subject: [PATCH 3/4] Fix Flake8 error E211 whitespace before '(' --- test/cfvtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cfvtest.py b/test/cfvtest.py index 3909cd6..e8917ac 100644 --- a/test/cfvtest.py +++ b/test/cfvtest.py @@ -149,7 +149,7 @@ def open_output(file): '__package__': None, } try: - exec (cfv_compiled, cfv_ns) + exec(cfv_compiled, cfv_ns) s = 'no exit?' except SystemExit as e: s = e.code From 81f1042aca4b1db63d38565dab542e2a7c223c06 Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Fri, 28 Oct 2022 23:46:10 +0200 Subject: [PATCH 4/4] CI: Do not ignore Flake8 errors --- .github/workflows/ci-python3-freebsd.yml | 2 +- .github/workflows/ci-python3.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-python3-freebsd.yml b/.github/workflows/ci-python3-freebsd.yml index f5dba0e..067fb9a 100644 --- a/.github/workflows/ci-python3-freebsd.yml +++ b/.github/workflows/ci-python3-freebsd.yml @@ -78,7 +78,7 @@ jobs: su runner -c 'check-manifest --ignore=Release.md .' # Run flake - flake8 --exclude=build,venv --ignore= --max-line-length=200 --max-complexity=75 --show-source --statistics . || true + flake8 --exclude=build,venv --ignore= --max-line-length=200 --max-complexity=75 --show-source --statistics . # Check distribution python setup.py sdist bdist_wheel diff --git a/.github/workflows/ci-python3.yml b/.github/workflows/ci-python3.yml index 6f46b9a..ba0f48d 100644 --- a/.github/workflows/ci-python3.yml +++ b/.github/workflows/ci-python3.yml @@ -68,7 +68,6 @@ jobs: run: check-manifest --ignore=Release.md . - name: Run flake - continue-on-error: true run: flake8 --exclude=build,venv --ignore= --max-line-length=200 --max-complexity=75 --show-source --statistics . - name: Check distribution