From 338a0cc3d4bdc2ba3b474678d22b989b2b2ac338 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 17 Feb 2022 19:10:47 -0300 Subject: [PATCH] Fixed B007 Loop control variable 'i' not used within the loop body. --- kibot/bom/csv_writer.py | 2 +- kibot/bom/xlsx_writer.py | 2 +- kibot/config_reader.py | 2 +- kibot/kicad/v6_sch.py | 6 +++--- kibot/layer.py | 2 +- tests/test_plot/test_preflight.py | 4 ++-- tests/utils/lzstring.py | 22 +++++++++++----------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/kibot/bom/csv_writer.py b/kibot/bom/csv_writer.py index 0a0c64a5..b38b73f4 100644 --- a/kibot/bom/csv_writer.py +++ b/kibot/bom/csv_writer.py @@ -100,7 +100,7 @@ def write_csv(filename, ext, groups, headings, head_names, cfg): # PCB info if not (cfg.csv.hide_pcb_info and cfg.csv.hide_stats_info): # Add some blank rows - for i in range(5): + for _ in range(5): writer.writerow([]) # The info write_stats(writer, cfg) diff --git a/kibot/bom/xlsx_writer.py b/kibot/bom/xlsx_writer.py index 51944d7e..420d2110 100644 --- a/kibot/bom/xlsx_writer.py +++ b/kibot/bom/xlsx_writer.py @@ -192,7 +192,7 @@ def create_col_fmt(col_fields, col_colors, fmt_cols): for c in col_fields: col_fmt.append(fmt_cols[bg_color(c)]) else: - for c in col_fields: + for _ in col_fields: col_fmt.append(fmt_cols[0]) # Empty color col_fmt.append(fmt_cols[-1]) diff --git a/kibot/config_reader.py b/kibot/config_reader.py index e66e0ab4..eb6e4c42 100644 --- a/kibot/config_reader.py +++ b/kibot/config_reader.py @@ -574,7 +574,7 @@ def print_example_options(f, cls, name, indent, po, is_list=False): first = True if po: obj.read_vals_from_po(po) - for k, v in obj.get_attrs_gen(): + for k, _ in obj.get_attrs_gen(): help, alias, is_alias = obj.get_doc(k) if is_alias: f.write(ind_str+'# `{}` is an alias for `{}`\n'.format(k, alias)) diff --git a/kibot/kicad/v6_sch.py b/kibot/kicad/v6_sch.py index f40f328e..2d254fa3 100644 --- a/kibot/kicad/v6_sch.py +++ b/kibot/kicad/v6_sch.py @@ -1375,7 +1375,7 @@ class SheetInstance(object): def parse(items): name = 'sheet instance' instances = [] - for c, i in enumerate(items[1:]): + for c, _ in enumerate(items[1:]): v = _check_symbol_value(items, c+1, name, 'path') instance = SheetInstance() instance.path = _check_str(v, 1, name+' path') @@ -1392,7 +1392,7 @@ class SymbolInstance(object): def parse(items): name = 'symbol instance' instances = [] - for c, i in enumerate(items[1:]): + for c, _ in enumerate(items[1:]): v = _check_symbol_value(items, c+1, name, 'path') instance = SymbolInstance() instance.path = _check_str(v, 1, name+' path') @@ -1429,7 +1429,7 @@ class PCBLayer(object): name = 'PCB stackup layer' layer = PCBLayer() layer.name = _check_str(items, 1, name) - for c, i in enumerate(items[2:]): + for i in items[2:]: i_type = _check_is_symbol_list(i) tname = name+' '+i_type if i_type == 'type': diff --git a/kibot/layer.py b/kibot/layer.py index 66686ab4..3f973ba7 100644 --- a/kibot/layer.py +++ b/kibot/layer.py @@ -229,7 +229,7 @@ class Layer(Optionable): @staticmethod def _get_layers(d_layers): layers = [] - for n, id in d_layers.items(): + for n in d_layers.keys(): layers.append(Layer.create_layer(n)) return layers diff --git a/tests/test_plot/test_preflight.py b/tests/test_plot/test_preflight.py index 80ea9452..1ee55abf 100644 --- a/tests/test_plot/test_preflight.py +++ b/tests/test_plot/test_preflight.py @@ -175,11 +175,11 @@ def test_sch_replace_1(test_dir): files[file] = file + '-bak' file = ctx.sch_file.replace('test_v5', 'sub-sheet') files[file] = file + '-bak' - for k, v in files.items(): + for v in files.values(): assert os.path.isfile(v), v assert os.path.getsize(v) > 0 try: - for k, v in files.items(): + for k in files.keys(): logging.debug(k) cmd = ['/bin/bash', '-c', "date -d @`git log -1 --format='%at' -- " + k + "` +%Y-%m-%d_%H-%M-%S"] text = run(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True).stdout.strip() diff --git a/tests/utils/lzstring.py b/tests/utils/lzstring.py index d341d934..114cf3c2 100644 --- a/tests/utils/lzstring.py +++ b/tests/utils/lzstring.py @@ -56,7 +56,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 else: if context_w in context_dictionaryToCreate: if ord(context_w[0]) < 256: - for i in range(context_numBits): + for _ in range(context_numBits): context_data_val = (context_data_val << 1) if context_data_position == bitsPerChar-1: context_data_position = 0 @@ -65,7 +65,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 else: context_data_position += 1 value = ord(context_w[0]) - for i in range(8): + for _ in range(8): context_data_val = (context_data_val << 1) | (value & 1) if context_data_position == bitsPerChar - 1: context_data_position = 0 @@ -77,7 +77,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 else: value = 1 - for i in range(context_numBits): + for _ in range(context_numBits): context_data_val = (context_data_val << 1) | value if context_data_position == bitsPerChar - 1: context_data_position = 0 @@ -87,7 +87,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 context_data_position += 1 value = 0 value = ord(context_w[0]) - for i in range(16): + for _ in range(16): context_data_val = (context_data_val << 1) | (value & 1) if context_data_position == bitsPerChar - 1: context_data_position = 0 @@ -103,7 +103,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 del context_dictionaryToCreate[context_w] else: value = context_dictionary[context_w] - for i in range(context_numBits): + for _ in range(context_numBits): context_data_val = (context_data_val << 1) | (value & 1) if context_data_position == bitsPerChar - 1: context_data_position = 0 @@ -127,7 +127,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 if context_w != "": if context_w in context_dictionaryToCreate: if ord(context_w[0]) < 256: - for i in range(context_numBits): + for _ in range(context_numBits): context_data_val = (context_data_val << 1) if context_data_position == bitsPerChar-1: context_data_position = 0 @@ -136,7 +136,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 else: context_data_position += 1 value = ord(context_w[0]) - for i in range(8): + for _ in range(8): context_data_val = (context_data_val << 1) | (value & 1) if context_data_position == bitsPerChar - 1: context_data_position = 0 @@ -147,7 +147,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 value = value >> 1 else: value = 1 - for i in range(context_numBits): + for _ in range(context_numBits): context_data_val = (context_data_val << 1) | value if context_data_position == bitsPerChar - 1: context_data_position = 0 @@ -157,7 +157,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 context_data_position += 1 value = 0 value = ord(context_w[0]) - for i in range(16): + for _ in range(16): context_data_val = (context_data_val << 1) | (value & 1) if context_data_position == bitsPerChar - 1: context_data_position = 0 @@ -173,7 +173,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 del context_dictionaryToCreate[context_w] else: value = context_dictionary[context_w] - for i in range(context_numBits): + for _ in range(context_numBits): context_data_val = (context_data_val << 1) | (value & 1) if context_data_position == bitsPerChar - 1: context_data_position = 0 @@ -190,7 +190,7 @@ def _compress(uncompressed, bitsPerChar, getCharFromInt): # noqa: C901 # Mark the end of the stream value = 2 - for i in range(context_numBits): + for _ in range(context_numBits): context_data_val = (context_data_val << 1) | (value & 1) if context_data_position == bitsPerChar - 1: context_data_position = 0