Skip to content

Commit

Permalink
Merge pull request #37 from cfv-project/fix-flake8-errors
Browse files Browse the repository at this point in the history
Fix flake8 errors and make flake8 fatal in CI (Fixes #19)
  • Loading branch information
lxp authored Oct 28, 2022
2 parents 52133b0 + 81f1042 commit 08ee267
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-python3-freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-python3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/cfv/BitTorrent/bencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# see LICENSE.txt for license information

from builtins import object
from builtins import str


def decode_int(x, f):
Expand Down
34 changes: 17 additions & 17 deletions lib/cfv/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) == ' ':
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/cfv/osutil.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from builtins import str

import locale
import os
import re
Expand Down Expand Up @@ -85,7 +83,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'))
Expand Down
6 changes: 3 additions & 3 deletions lib/cfv/strutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions test/cfvtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def isatty(self):
def write(self, s):
pass

def writelines(self, l):
def writelines(self, lines):
pass

def flush(self):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 08ee267

Please sign in to comment.