[flake8] Fixed reported issues

This commit is contained in:
Salvador E. Tropea 2024-01-05 09:33:42 -03:00
parent d7392d59ec
commit 6f7d425ee1
12 changed files with 30 additions and 30 deletions

View File

@ -59,19 +59,19 @@ repos:
hooks:
- id: autoflake8
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.0.0
hooks:
- id: flake8
exclude: ^kibot/mcpyrate/
args: [--count, --statistics]
additional_dependencies:
- flake8-bugbear==22.1.11
- flake8-comprehensions==3.8.0
- flake8_2020==1.6.1
- flake8-bugbear>=22.1.11
- flake8-comprehensions>=3.8.0
- flake8_2020>=1.6.1
- flake8-docstrings
- mccabe==0.6.1
- pycodestyle==2.8.0
- pyflakes==2.4.0
- mccabe>=0.6.1
- pycodestyle>=2.8.0
- pyflakes>=2.4.0
# Sorting imports is dangerous.
# - repo: https://github.com/PyCQA/isort
# rev: 5.10.1

View File

@ -340,7 +340,7 @@ class CfgYamlReader(object):
if explicit_outs:
logger.warning(W_NOOUTPUTS+"No outputs found in `{}`".format(fn_rel))
else:
logger.debug('Outputs loaded from `{}`: {}'.format(fn_rel, (c.name for c in sel_outs)))
logger.debug('Outputs loaded from `{}`: {}'.format(fn_rel, [c.name for c in sel_outs]))
if outs is None and explicit_outs and 'outputs' not in data:
logger.warning(W_NOOUTPUTS+"No outputs found in `{}`".format(fn_rel))
return sel_outs
@ -364,7 +364,7 @@ class CfgYamlReader(object):
if explicit_pres:
logger.warning(W_NOPREFLIGHTS+"No preflights found in `{}`".format(fn_rel))
else:
logger.debug('Preflights loaded from `{}`: {}'.format(fn_rel, (c._name for c in sel_pres)))
logger.debug('Preflights loaded from `{}`: {}'.format(fn_rel, [c._name for c in sel_pres]))
if pre is None and explicit_pres and 'preflight' not in data:
logger.warning(W_NOPREFLIGHTS+"No preflights found in `{}`".format(fn_rel))
return sel_pres

View File

@ -625,7 +625,7 @@ class GS(object):
For tuples we assume the result is SVG coordinates, for 1 value a scale """
if GS.ki5:
if isinstance(values, tuple):
return (int(round(x*KICAD5_SVG_SCALE)) for x in values)
return tuple(int(round(x*KICAD5_SVG_SCALE)) for x in values)
return values*KICAD5_SVG_SCALE
if GS.ki7:
if isinstance(values, tuple):
@ -634,7 +634,7 @@ class GS(object):
# KiCad 6
mult = 10.0 ** (svg_precision - 6)
if isinstance(values, tuple):
return (int(round(x*mult)) for x in values)
return tuple(int(round(x*mult)) for x in values)
return values*mult
@staticmethod

View File

@ -2053,7 +2053,7 @@ class SchematicV6(Schematic):
# 0 or 1 can't be different
continue
ref_c = l_ins[0]
if any(map(lambda c: self.compare_component(ref_c, c), l_ins[1:])):
if any((self.compare_component(ref_c, c) for c in l_ins[1:])):
return True
# No variant
return False

View File

@ -121,7 +121,7 @@ class MyLogger(logging.Logger):
if isinstance(msg, tuple):
msg = ' '.join(map(str, msg))
if sys.version_info >= (3, 8):
super(self.__class__, self).debug(msg, stacklevel=2, *args, **kwargs) # pragma: no cover (Py38)
super(self.__class__, self).debug(msg, *args, **kwargs, stacklevel=2) # pragma: no cover (Py38)
else:
super(self.__class__, self).debug(msg, *args, **kwargs)
@ -140,7 +140,7 @@ class MyLogger(logging.Logger):
if isinstance(msg, tuple):
msg = ' '.join(map(str, msg))
if sys.version_info >= (3, 8):
super(self.__class__, self).debug(msg, stacklevel=2, *args, **kwargs) # pragma: no cover (Py38)
super(self.__class__, self).debug(msg, *args, **kwargs, stacklevel=2) # pragma: no cover (Py38)
else:
super(self.__class__, self).debug(msg, *args, **kwargs)

View File

@ -349,7 +349,7 @@ class Optionable(object):
# Replace KiCad 6 variables first
name = GS.expand_text_variables(name)
# Determine if we need to expand SCH and/or PCB related data
has_dep_exp = any(map(lambda x: x in name, PATTERNS_DEP))
has_dep_exp = any((x in name for x in PATTERNS_DEP))
do_sch = is_sch and has_dep_exp
# logger.error(name + ' is_sch ' +str(is_sch)+" "+ str(do_sch))
# raise

View File

@ -318,7 +318,7 @@ class Base3DOptions(VariantOptions):
m = coo_re.match(ln)
if m:
index = prev_ln
points = list(map(lambda x: tuple(map(float, x.split(' '))), m.group(1).split(',')))
points = [(float(v) for v in x.split(' ')) for x in m.group(1).split(',')]
x_len = (points[0][X]-points[2][X])*2.54*2
if abs(x_len-r_len) < 0.01:
logger.debug(' - Found horizontal: {}'.format(round(x_len, 2)))
@ -418,7 +418,7 @@ class Base3DOptions(VariantOptions):
bars[bar] = ord(val_str[bar])-ord('0')
# Make sure we don't have digits that can't be represented
rest = val_str[dig_bars:]
if rest and not all(map(lambda x: x == '0', rest)):
if rest and not all((x == '0' for x in rest)):
logger.warning(W_RESVALISSUE+'Digits not represented in {} {} ({} %)'.format(c.ref, c.value, tol))
bars[nbars-1] = tol_color
# For 20% remove the last bar
@ -550,7 +550,7 @@ class Base3DOptions(VariantOptions):
GS.load_sch()
all_comps = GS.sch.get_components()
if (GS.global_kicad_dnp_applies_to_3D and
any(map(lambda c: c.kicad_dnp is not None and c.kicad_dnp, all_comps))):
any((c.kicad_dnp is not None and c.kicad_dnp for c in all_comps))):
# One or more components are DNP, remove them
reset_filters(all_comps)
all_comps_hash = {c.ref: c for c in all_comps}

View File

@ -58,8 +58,8 @@ def convert(pcb, brd):
pcb.GetBoardPolygonOutlines(outlines)
outline = outlines.Outline(0)
outline_points = [outline.GetPoint(n) for n in range(outline.GetPointCount())]
outline_maxx = max(map(lambda p: p.x, outline_points))
outline_maxy = max(map(lambda p: p.y, outline_points))
outline_maxx = max((p.x for p in outline_points))
outline_maxy = max((p.y for p in outline_points))
brd.write("0\n") # unknown

View File

@ -202,7 +202,7 @@ class LineElement(FigureElement):
def __init__(self, points, width=1, color="black"):
linedata = "M{} {} ".format(*points[0])
linedata += " ".join(map(lambda x: "L{} {}".format(*x), points[1:]))
linedata += " ".join(("L{} {}".format(*x) for x in points[1:]))
line = etree.Element(
SVG + "path", {"d": linedata, "stroke-width": str(width), "stroke": color}
)

View File

@ -287,10 +287,10 @@ class SubPCBOptions(PanelOptions):
def move_objects(self):
""" Move all objects by self._moved """
logger.debug('Moving all PCB elements by '+point_str(self._moved))
any(map(lambda x: x.Move(self._moved), GS.get_modules()))
any(map(lambda x: x.Move(self._moved), GS.board.GetDrawings()))
any(map(lambda x: x.Move(self._moved), GS.board.GetTracks()))
any(map(lambda x: x.Move(self._moved), GS.board.Zones()))
any((x.Move(self._moved) for x in GS.get_modules()))
any((x.Move(self._moved) for x in GS.board.GetDrawings()))
any((x.Move(self._moved) for x in GS.board.GetTracks()))
any((x.Move(self._moved) for x in GS.board.Zones()))
def center_objects(self):
""" Move all objects in the PCB so it gets centered """

View File

@ -27,10 +27,10 @@ def convert2csv(ctx, xlsx, skip_empty=False, sheet=None):
subprocess.check_output(cmd)
with open(csv, 'rt') as f:
content = f.read()
content = re.sub(r'(\$|Prj) date:,[^,]+', r'\1 date:,', content, 3)
content = re.sub(r'KiCost[^,]+', 'KiCost', content, 1)
content = re.sub(r'(\$|Prj) date:,[^,]+', r'\1 date:,', content, count=3)
content = re.sub(r'KiCost[^,]+', 'KiCost', content, count=1)
content = re.sub(r'KiCad Version:,[^,]+', 'KiCad Version:,', content)
content = re.sub(r'Created:,[^,]+', 'Created:,', content, 1)
content = re.sub(r'Created:,[^,]+', 'Created:,', content, count=1)
with open(csv, 'wt') as f:
f.write(content)

View File

@ -546,8 +546,8 @@ class TestContext(object):
# logging.debug('MSE={} ({})'.format(m.group(1), m.group(2)))
s = res.decode()
# Remove error messages generated by KiCad 7 plotted PDFs
s = re.sub(r'^\s+\*+.*', '', s, 0, re.M)
s = re.sub(r'^\s+Output may be incorrect.*', '', s, 0, re.M)
s = re.sub(r'^\s+\*+.*', '', s, count=0, flags=re.M)
s = re.sub(r'^\s+Output may be incorrect.*', '', s, count=0, flags=re.M)
s = s.strip()
ae = int(s)
logging.debug('AE=%d' % ae)