diff options
author | Zach White <skullydazed@gmail.com> | 2021-09-27 10:02:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-27 10:02:54 -0700 |
commit | fce9cb933845bf0b74d322eba02de3b76daaeb84 (patch) | |
tree | a28ffc6f3c53a4ddf1004f1a99938e2e5a42e6c3 | |
parent | 5f38a98fa07677be960b71b8e3b0a1785effe0d8 (diff) | |
download | qmk_firmware-fce9cb933845bf0b74d322eba02de3b76daaeb84.tar.gz qmk_firmware-fce9cb933845bf0b74d322eba02de3b76daaeb84.zip |
Cleanup issues identified by lgtm (#14459)
* cleanup issues identified by lgtm
* fix the git_status check
-rw-r--r-- | keyboards/dekunukem/duckypad/keymaps/m4cs/sysinfo.py | 1 | ||||
-rwxr-xr-x | keyboards/ergodox_ez/util/compile_keymap.py | 5 | ||||
-rwxr-xr-x | keyboards/ergodox_ez/util/keymap_beautifier/KeymapBeautifier.py | 1 | ||||
-rwxr-xr-x | layouts/community/ergodox/algernon/tools/log-to-heatmap.py | 4 | ||||
-rwxr-xr-x | layouts/community/ergodox/algernon/tools/text-to-log.py | 1 | ||||
-rw-r--r-- | layouts/community/ergodox/german-manuneo/compile_keymap.py | 5 | ||||
-rw-r--r-- | lib/python/qmk/cli/doctor/linux.py | 8 | ||||
-rwxr-xr-x | lib/python/qmk/cli/doctor/main.py | 9 | ||||
-rwxr-xr-x | lib/python/qmk/cli/generate/config_h.py | 2 | ||||
-rw-r--r-- | lib/python/qmk/cli/generate/dfu_header.py | 2 | ||||
-rwxr-xr-x | lib/python/qmk/cli/generate/keyboard_h.py | 2 | ||||
-rwxr-xr-x | lib/python/qmk/cli/generate/layouts.py | 2 | ||||
-rw-r--r-- | lib/python/qmk/info.py | 8 | ||||
-rw-r--r-- | lib/python/qmk/keymap.py | 4 | ||||
-rw-r--r-- | users/dennytom/chording_engine/chord.py | 3 | ||||
-rwxr-xr-x | util/stm32eeprom_parser.py | 1 | ||||
-rwxr-xr-x | util/uf2conv.py | 8 |
17 files changed, 24 insertions, 42 deletions
diff --git a/keyboards/dekunukem/duckypad/keymaps/m4cs/sysinfo.py b/keyboards/dekunukem/duckypad/keymaps/m4cs/sysinfo.py index 04cf343ea..4dfcd4d4d 100644 --- a/keyboards/dekunukem/duckypad/keymaps/m4cs/sysinfo.py +++ b/keyboards/dekunukem/duckypad/keymaps/m4cs/sysinfo.py | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | import hid | 22 | import hid |
23 | import time | 23 | import time |
24 | import string | ||
25 | import psutil | 24 | import psutil |
26 | import GPUtil | 25 | import GPUtil |
27 | import datetime | 26 | import datetime |
diff --git a/keyboards/ergodox_ez/util/compile_keymap.py b/keyboards/ergodox_ez/util/compile_keymap.py index f427d6fd8..b447ecaf5 100755 --- a/keyboards/ergodox_ez/util/compile_keymap.py +++ b/keyboards/ergodox_ez/util/compile_keymap.py | |||
@@ -584,11 +584,6 @@ def unicode_macro_cases(config): | |||
584 | for macro_id, uc_hex in config['unicode_macros'].items(): | 584 | for macro_id, uc_hex in config['unicode_macros'].items(): |
585 | hi = int(uc_hex, 16) >> 8 | 585 | hi = int(uc_hex, 16) >> 8 |
586 | lo = int(uc_hex, 16) & 0xFF | 586 | lo = int(uc_hex, 16) & 0xFF |
587 | unimacro_keys = ", ".join( | ||
588 | "T({})".format( | ||
589 | "KP_" + digit if digit.isdigit() else digit | ||
590 | ) for digit in uc_hex | ||
591 | ) | ||
592 | yield UNICODE_MACRO_TEMPLATE.format( | 587 | yield UNICODE_MACRO_TEMPLATE.format( |
593 | macro_id=macro_id, hi=hi, lo=lo | 588 | macro_id=macro_id, hi=hi, lo=lo |
594 | ) | 589 | ) |
diff --git a/keyboards/ergodox_ez/util/keymap_beautifier/KeymapBeautifier.py b/keyboards/ergodox_ez/util/keymap_beautifier/KeymapBeautifier.py index f55bdaf2d..9beee3796 100755 --- a/keyboards/ergodox_ez/util/keymap_beautifier/KeymapBeautifier.py +++ b/keyboards/ergodox_ez/util/keymap_beautifier/KeymapBeautifier.py | |||
@@ -227,7 +227,6 @@ class KeymapBeautifier: | |||
227 | self.layer_keys_pointer = 0 | 227 | self.layer_keys_pointer = 0 |
228 | 228 | ||
229 | begin = self.layer_keys_pointer | 229 | begin = self.layer_keys_pointer |
230 | end = begin + n_columns | ||
231 | return self.layer_keys[self.layer_keys_pointer-n_keys:self.layer_keys_pointer] | 230 | return self.layer_keys[self.layer_keys_pointer-n_keys:self.layer_keys_pointer] |
232 | 231 | ||
233 | key_coordinates_counter = 0 | 232 | key_coordinates_counter = 0 |
diff --git a/layouts/community/ergodox/algernon/tools/log-to-heatmap.py b/layouts/community/ergodox/algernon/tools/log-to-heatmap.py index e927e0e39..5f52d9932 100755 --- a/layouts/community/ergodox/algernon/tools/log-to-heatmap.py +++ b/layouts/community/ergodox/algernon/tools/log-to-heatmap.py | |||
@@ -8,7 +8,6 @@ import time | |||
8 | 8 | ||
9 | from math import floor | 9 | from math import floor |
10 | from os.path import dirname | 10 | from os.path import dirname |
11 | from subprocess import Popen, PIPE, STDOUT | ||
12 | from blessings import Terminal | 11 | from blessings import Terminal |
13 | 12 | ||
14 | class Heatmap(object): | 13 | class Heatmap(object): |
@@ -122,7 +121,6 @@ class Heatmap(object): | |||
122 | 121 | ||
123 | for (c, r) in self.log: | 122 | for (c, r) in self.log: |
124 | coords = self.coord(c, r) | 123 | coords = self.coord(c, r) |
125 | b, n = coords | ||
126 | cap = self.max_cnt | 124 | cap = self.max_cnt |
127 | if cap == 0: | 125 | if cap == 0: |
128 | cap = 1 | 126 | cap = 1 |
@@ -302,7 +300,7 @@ def main(opts): | |||
302 | break | 300 | break |
303 | if not process_line(line, heatmaps, opts): | 301 | if not process_line(line, heatmaps, opts): |
304 | continue | 302 | continue |
305 | except: | 303 | except Exception: |
306 | pass | 304 | pass |
307 | 305 | ||
308 | stamped_log = open ("%s/stamped-log" % (out_dir), "a+") | 306 | stamped_log = open ("%s/stamped-log" % (out_dir), "a+") |
diff --git a/layouts/community/ergodox/algernon/tools/text-to-log.py b/layouts/community/ergodox/algernon/tools/text-to-log.py index f080c32cd..ba60a2e28 100755 --- a/layouts/community/ergodox/algernon/tools/text-to-log.py +++ b/layouts/community/ergodox/algernon/tools/text-to-log.py | |||
@@ -1,6 +1,5 @@ | |||
1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
2 | 2 | ||
3 | import os | ||
4 | import sys | 3 | import sys |
5 | 4 | ||
6 | charmap = { | 5 | charmap = { |
diff --git a/layouts/community/ergodox/german-manuneo/compile_keymap.py b/layouts/community/ergodox/german-manuneo/compile_keymap.py index 9ad5c88ec..df5d42984 100644 --- a/layouts/community/ergodox/german-manuneo/compile_keymap.py +++ b/layouts/community/ergodox/german-manuneo/compile_keymap.py | |||
@@ -584,11 +584,6 @@ def unicode_macro_cases(config): | |||
584 | for macro_id, uc_hex in config['unicode_macros'].items(): | 584 | for macro_id, uc_hex in config['unicode_macros'].items(): |
585 | hi = int(uc_hex, 16) >> 8 | 585 | hi = int(uc_hex, 16) >> 8 |
586 | lo = int(uc_hex, 16) & 0xFF | 586 | lo = int(uc_hex, 16) & 0xFF |
587 | unimacro_keys = ", ".join( | ||
588 | "T({})".format( | ||
589 | "KP_" + digit if digit.isdigit() else digit | ||
590 | ) for digit in uc_hex | ||
591 | ) | ||
592 | yield UNICODE_MACRO_TEMPLATE.format( | 587 | yield UNICODE_MACRO_TEMPLATE.format( |
593 | macro_id=macro_id, hi=hi, lo=lo | 588 | macro_id=macro_id, hi=hi, lo=lo |
594 | ) | 589 | ) |
diff --git a/lib/python/qmk/cli/doctor/linux.py b/lib/python/qmk/cli/doctor/linux.py index 6ce00f6ef..94683d330 100644 --- a/lib/python/qmk/cli/doctor/linux.py +++ b/lib/python/qmk/cli/doctor/linux.py | |||
@@ -118,10 +118,9 @@ def check_udev_rules(): | |||
118 | cli.log.warning("{fg_yellow}Found old, deprecated udev rules for '%s' boards. The new rules on https://docs.qmk.fm/#/faq_build?id=linux-udev-rules offer better security with the same functionality.", bootloader) | 118 | cli.log.warning("{fg_yellow}Found old, deprecated udev rules for '%s' boards. The new rules on https://docs.qmk.fm/#/faq_build?id=linux-udev-rules offer better security with the same functionality.", bootloader) |
119 | else: | 119 | else: |
120 | # For caterina, check if ModemManager is running | 120 | # For caterina, check if ModemManager is running |
121 | if bootloader == "caterina": | 121 | if bootloader == "caterina" and check_modem_manager(): |
122 | if check_modem_manager(): | 122 | cli.log.warning("{fg_yellow}Detected ModemManager without the necessary udev rules. Please either disable it or set the appropriate udev rules if you are using a Pro Micro.") |
123 | rc = CheckStatus.WARNING | 123 | |
124 | cli.log.warning("{fg_yellow}Detected ModemManager without the necessary udev rules. Please either disable it or set the appropriate udev rules if you are using a Pro Micro.") | ||
125 | rc = CheckStatus.WARNING | 124 | rc = CheckStatus.WARNING |
126 | cli.log.warning("{fg_yellow}Missing or outdated udev rules for '%s' boards. Run 'sudo cp %s/util/udev/50-qmk.rules /etc/udev/rules.d/'.", bootloader, QMK_FIRMWARE) | 125 | cli.log.warning("{fg_yellow}Missing or outdated udev rules for '%s' boards. Run 'sudo cp %s/util/udev/50-qmk.rules /etc/udev/rules.d/'.", bootloader, QMK_FIRMWARE) |
127 | 126 | ||
@@ -167,6 +166,5 @@ def os_test_linux(): | |||
167 | return CheckStatus.OK | 166 | return CheckStatus.OK |
168 | else: | 167 | else: |
169 | cli.log.info("Detected {fg_cyan}Linux{fg_reset}.") | 168 | cli.log.info("Detected {fg_cyan}Linux{fg_reset}.") |
170 | from .linux import check_udev_rules | ||
171 | 169 | ||
172 | return check_udev_rules() | 170 | return check_udev_rules() |
diff --git a/lib/python/qmk/cli/doctor/main.py b/lib/python/qmk/cli/doctor/main.py index 6a31ccdfd..ed20f46d3 100755 --- a/lib/python/qmk/cli/doctor/main.py +++ b/lib/python/qmk/cli/doctor/main.py | |||
@@ -79,12 +79,13 @@ def doctor(cli): | |||
79 | cli.log.info('CLI version: %s', cli.version) | 79 | cli.log.info('CLI version: %s', cli.version) |
80 | cli.log.info('QMK home: {fg_cyan}%s', QMK_FIRMWARE) | 80 | cli.log.info('QMK home: {fg_cyan}%s', QMK_FIRMWARE) |
81 | 81 | ||
82 | status = os_tests() | 82 | status = os_status = os_tests() |
83 | git_status = git_tests() | ||
83 | 84 | ||
84 | status = git_tests() | 85 | if git_status == CheckStatus.ERROR or (os_status == CheckStatus.OK and git_status == CheckStatus.WARNING): |
86 | status = git_status | ||
85 | 87 | ||
86 | venv = in_virtualenv() | 88 | if in_virtualenv(): |
87 | if venv: | ||
88 | cli.log.info('CLI installed in virtualenv.') | 89 | cli.log.info('CLI installed in virtualenv.') |
89 | 90 | ||
90 | # Make sure the basic CLI tools we need are available and can be executed. | 91 | # Make sure the basic CLI tools we need are available and can be executed. |
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index ca7e14fe6..f16dca1de 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py | |||
@@ -173,7 +173,7 @@ def generate_config_h(cli): | |||
173 | kb_info_json = dotty(info_json(cli.args.keyboard)) | 173 | kb_info_json = dotty(info_json(cli.args.keyboard)) |
174 | 174 | ||
175 | # Build the info_config.h file. | 175 | # Build the info_config.h file. |
176 | config_h_lines = ['/* This file was generated by `qmk generate-config-h`. Do not edit or copy.' ' */', '', '#pragma once'] | 176 | config_h_lines = ['/* This file was generated by `qmk generate-config-h`. Do not edit or copy.', ' */', '', '#pragma once'] |
177 | 177 | ||
178 | generate_config_items(kb_info_json, config_h_lines) | 178 | generate_config_items(kb_info_json, config_h_lines) |
179 | 179 | ||
diff --git a/lib/python/qmk/cli/generate/dfu_header.py b/lib/python/qmk/cli/generate/dfu_header.py index 211ed9991..5a1b109f1 100644 --- a/lib/python/qmk/cli/generate/dfu_header.py +++ b/lib/python/qmk/cli/generate/dfu_header.py | |||
@@ -30,7 +30,7 @@ def generate_dfu_header(cli): | |||
30 | # Build the Keyboard.h file. | 30 | # Build the Keyboard.h file. |
31 | kb_info_json = dotty(info_json(cli.config.generate_dfu_header.keyboard)) | 31 | kb_info_json = dotty(info_json(cli.config.generate_dfu_header.keyboard)) |
32 | 32 | ||
33 | keyboard_h_lines = ['/* This file was generated by `qmk generate-dfu-header`. Do not edit or copy.' ' */', '', '#pragma once'] | 33 | keyboard_h_lines = ['/* This file was generated by `qmk generate-dfu-header`. Do not edit or copy.', ' */', '', '#pragma once'] |
34 | keyboard_h_lines.append(f'#define MANUFACTURER {kb_info_json["manufacturer"]}') | 34 | keyboard_h_lines.append(f'#define MANUFACTURER {kb_info_json["manufacturer"]}') |
35 | keyboard_h_lines.append(f'#define PRODUCT {cli.config.generate_dfu_header.keyboard} Bootloader') | 35 | keyboard_h_lines.append(f'#define PRODUCT {cli.config.generate_dfu_header.keyboard} Bootloader') |
36 | 36 | ||
diff --git a/lib/python/qmk/cli/generate/keyboard_h.py b/lib/python/qmk/cli/generate/keyboard_h.py index c9d7f549b..f05178ced 100755 --- a/lib/python/qmk/cli/generate/keyboard_h.py +++ b/lib/python/qmk/cli/generate/keyboard_h.py | |||
@@ -36,7 +36,7 @@ def generate_keyboard_h(cli): | |||
36 | has_layout_h = would_populate_layout_h(cli.args.keyboard) | 36 | has_layout_h = would_populate_layout_h(cli.args.keyboard) |
37 | 37 | ||
38 | # Build the layouts.h file. | 38 | # Build the layouts.h file. |
39 | keyboard_h_lines = ['/* This file was generated by `qmk generate-keyboard-h`. Do not edit or copy.' ' */', '', '#pragma once', '#include "quantum.h"'] | 39 | keyboard_h_lines = ['/* This file was generated by `qmk generate-keyboard-h`. Do not edit or copy.', ' */', '', '#pragma once', '#include "quantum.h"'] |
40 | 40 | ||
41 | if not has_layout_h: | 41 | if not has_layout_h: |
42 | keyboard_h_lines.append('#pragma error("<keyboard>.h is only optional for data driven keyboards - kb.h == bad times")') | 42 | keyboard_h_lines.append('#pragma error("<keyboard>.h is only optional for data driven keyboards - kb.h == bad times")') |
diff --git a/lib/python/qmk/cli/generate/layouts.py b/lib/python/qmk/cli/generate/layouts.py index 4de982f82..e44266e1c 100755 --- a/lib/python/qmk/cli/generate/layouts.py +++ b/lib/python/qmk/cli/generate/layouts.py | |||
@@ -38,7 +38,7 @@ def generate_layouts(cli): | |||
38 | kb_info_json = info_json(cli.config.generate_layouts.keyboard) | 38 | kb_info_json = info_json(cli.config.generate_layouts.keyboard) |
39 | 39 | ||
40 | # Build the layouts.h file. | 40 | # Build the layouts.h file. |
41 | layouts_h_lines = ['/* This file was generated by `qmk generate-layouts`. Do not edit or copy.' ' */', '', '#pragma once'] | 41 | layouts_h_lines = ['/* This file was generated by `qmk generate-layouts`. Do not edit or copy.', ' */', '', '#pragma once'] |
42 | 42 | ||
43 | if 'matrix_pins' in kb_info_json: | 43 | if 'matrix_pins' in kb_info_json: |
44 | if 'direct' in kb_info_json['matrix_pins']: | 44 | if 'direct' in kb_info_json['matrix_pins']: |
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 7f3aabdc3..1b4c42ff4 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py | |||
@@ -29,10 +29,10 @@ def info_json(keyboard): | |||
29 | """Generate the info.json data for a specific keyboard. | 29 | """Generate the info.json data for a specific keyboard. |
30 | """ | 30 | """ |
31 | cur_dir = Path('keyboards') | 31 | cur_dir = Path('keyboards') |
32 | rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') | 32 | root_rules_mk = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') |
33 | if 'DEFAULT_FOLDER' in rules: | 33 | |
34 | keyboard = rules['DEFAULT_FOLDER'] | 34 | if 'DEFAULT_FOLDER' in root_rules_mk: |
35 | rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk', rules) | 35 | keyboard = root_rules_mk['DEFAULT_FOLDER'] |
36 | 36 | ||
37 | info_data = { | 37 | info_data = { |
38 | 'keyboard_name': str(keyboard), | 38 | 'keyboard_name': str(keyboard), |
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index 2d5921e7a..6eec49cfd 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py | |||
@@ -149,8 +149,8 @@ def is_keymap_dir(keymap, c=True, json=True, additional_files=None): | |||
149 | for file in files: | 149 | for file in files: |
150 | if (keymap / file).is_file(): | 150 | if (keymap / file).is_file(): |
151 | if additional_files: | 151 | if additional_files: |
152 | for file in additional_files: | 152 | for additional_file in additional_files: |
153 | if not (keymap / file).is_file(): | 153 | if not (keymap / additional_file).is_file(): |
154 | return False | 154 | return False |
155 | 155 | ||
156 | return True | 156 | return True |
diff --git a/users/dennytom/chording_engine/chord.py b/users/dennytom/chording_engine/chord.py index 707f36b82..5e3b6d283 100644 --- a/users/dennytom/chording_engine/chord.py +++ b/users/dennytom/chording_engine/chord.py | |||
@@ -1,5 +1,4 @@ | |||
1 | from functools import reduce | 1 | from functools import reduce |
2 | import re | ||
3 | 2 | ||
4 | strings = [] | 3 | strings = [] |
5 | number_of_strings = -1 | 4 | number_of_strings = -1 |
@@ -463,4 +462,4 @@ def secret_chord(PSEUDOLAYER, ACTION, INPUT_STRING, data, output_buffer, index, | |||
463 | 462 | ||
464 | hash = hash[3:] | 463 | hash = hash[3:] |
465 | if hash != "": | 464 | if hash != "": |
466 | return add_key(PSEUDOLAYER, hash, ACTION, output_buffer, index, number_of_strings, strings) \ No newline at end of file | 465 | return add_key(PSEUDOLAYER, hash, ACTION, output_buffer, index, number_of_strings, strings) |
diff --git a/util/stm32eeprom_parser.py b/util/stm32eeprom_parser.py index b124f713d..e08b67064 100755 --- a/util/stm32eeprom_parser.py +++ b/util/stm32eeprom_parser.py | |||
@@ -197,7 +197,6 @@ def dumpBinary(data, canonical): | |||
197 | print("") | 197 | print("") |
198 | 198 | ||
199 | size = len(data) | 199 | size = len(data) |
200 | empty_rows = 0 | ||
201 | prev_row = '' | 200 | prev_row = '' |
202 | first_repeat = True | 201 | first_repeat = True |
203 | for pos in range(0, size, 16): | 202 | for pos in range(0, size, 16): |
diff --git a/util/uf2conv.py b/util/uf2conv.py index 044a7f231..8677a828c 100755 --- a/util/uf2conv.py +++ b/util/uf2conv.py | |||
@@ -78,7 +78,7 @@ def convert_from_uf2(buf): | |||
78 | if datalen > 476: | 78 | if datalen > 476: |
79 | assert False, "Invalid UF2 data size at " + ptr | 79 | assert False, "Invalid UF2 data size at " + ptr |
80 | newaddr = hd[3] | 80 | newaddr = hd[3] |
81 | if curraddr == None: | 81 | if curraddr is None: |
82 | appstartaddr = newaddr | 82 | appstartaddr = newaddr |
83 | curraddr = newaddr | 83 | curraddr = newaddr |
84 | padding = newaddr - curraddr | 84 | padding = newaddr - curraddr |
@@ -171,7 +171,7 @@ def convert_from_hex_to_uf2(buf): | |||
171 | break | 171 | break |
172 | elif tp == 0: | 172 | elif tp == 0: |
173 | addr = upper | (rec[1] << 8) | rec[2] | 173 | addr = upper | (rec[1] << 8) | rec[2] |
174 | if appstartaddr == None: | 174 | if appstartaddr is None: |
175 | appstartaddr = addr | 175 | appstartaddr = addr |
176 | i = 4 | 176 | i = 4 |
177 | while i < len(rec) - 1: | 177 | while i < len(rec) - 1: |
@@ -215,7 +215,7 @@ def get_drives(): | |||
215 | def has_info(d): | 215 | def has_info(d): |
216 | try: | 216 | try: |
217 | return os.path.isfile(d + INFO_FILE) | 217 | return os.path.isfile(d + INFO_FILE) |
218 | except: | 218 | except Exception: |
219 | return False | 219 | return False |
220 | 220 | ||
221 | return list(filter(has_info, drives)) | 221 | return list(filter(has_info, drives)) |
@@ -300,7 +300,7 @@ def main(): | |||
300 | (ext, len(outbuf), appstartaddr)) | 300 | (ext, len(outbuf), appstartaddr)) |
301 | if args.convert or ext != "uf2": | 301 | if args.convert or ext != "uf2": |
302 | drives = [] | 302 | drives = [] |
303 | if args.output == None: | 303 | if args.output is None: |
304 | args.output = "flash." + ext | 304 | args.output = "flash." + ext |
305 | else: | 305 | else: |
306 | drives = get_drives() | 306 | drives = get_drives() |