KMKfw / kmk_firmware

Clackety Keyboards Powered by Python
https://kmkfw.zulipchat.com
Other
1.45k stars 485 forks source link

log error when the coordmapping is not guessable #1016

Closed JanLunge closed 3 months ago

JanLunge commented 3 months ago

I just ran into an error on a split keyboard with direct pin wiring. when not having a coordmap yet (still testing the keys with the helper to log the keys coordmapping index) KMK would just error with "NoneType has no len()" this did not help me much in debugging this issue.

the cause was that with a custom scanner the keyboard.row_pins and keyboard.col_pins are not set and then the split during_bootup cannot guess a coordmap. I added a print statement that tells the user the coordmapping is missing when both of these are not defined on the keyboard as either the pins are required or the coordmap.

JanLunge commented 3 months ago

ok there seems to more issues on linting than i would have expected the make fix-isort fix-formatting test doesn't work on my mac currently and the error with "black wants to make changes" will have me debugging this for a bit. no need to rerun workflows until then, my bad.

xs5871 commented 3 months ago

The fix-* targets can't fix everything for you. Run make lint and it'll tell you what it's unhappy about.

JanLunge commented 3 months ago

ok the issue was the line length, I added a shorter error message. btw i think tomli is missing from the pipfile at least I needed to install it first

xs5871 commented 3 months ago

btw i think tomli is missing from the pipfile at least I needed to install it first

No, why would that be necessary?

JanLunge commented 3 months ago

I'm not familiar with flake8 so this was the output I got after running make lint


 File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/plugins/finder.py", line 291, in _load_plugin
    obj = plugin.entry_point.load()
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8_black.py", line 14, in <module>
    import tomli as tomllib
ModuleNotFoundError: No module named 'tomli'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/main/cli.py", line 23, in main
    app.run(argv)
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/main/application.py", line 198, in run
    self._run(argv)
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/main/application.py", line 186, in _run
    self.initialize(argv)
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/main/application.py", line 165, in initialize
    self.plugins, self.options = parse_args(argv)
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/options/parse_args.py", line 42, in parse_args
    plugins = finder.load_plugins(raw_plugins, plugin_opts)
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/plugins/finder.py", line 365, in load_plugins
    return _classify_plugins(_import_plugins(plugins, opts), opts)
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/plugins/finder.py", line 307, in _import_plugins
    return [_load_plugin(p) for p in plugins]
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/plugins/finder.py", line 307, in <listcomp>
    return [_load_plugin(p) for p in plugins]
  File "/Users/janlunge/.local/share/virtualenvs/kmk_firmware-pYd9idiz/lib/python3.10/site-packages/flake8/plugins/finder.py", line 293, in _load_plugin
    raise FailedToLoadPlugin(plugin.package, e)
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "flake8-black" due to No module named 'tomli'.
make: *** [lint] Error 1```
xs5871 commented 3 months ago

That is unusual. Maybe it's homebrew being weird, but it's definitely not a universal issue.

leiserfg commented 5 days ago

I'm a bit late to the party, but this change causes a spurious print when keyboard.coord_mapping is set.