Update lint to check all keymaps within the repo (#25970)

This commit is contained in:
Joel Challis
2026-03-13 23:20:28 +00:00
committed by GitHub
parent 53953f4229
commit f7a77c8b70
2 changed files with 28 additions and 24 deletions
+10 -10
View File
@@ -22,15 +22,10 @@ INVALID_KM_NAMES = ['via', 'vial']
def _list_defaultish_keymaps(kb):
"""Return default like keymaps for a given keyboard
"""
defaultish = ['ansi', 'iso']
keymaps = set(list_keymaps(kb, include_userspace=False, include_community=False))
# This is only here to flag it as "testable", so it doesn't fly under the radar during PR
defaultish.extend(INVALID_KM_NAMES)
keymaps = set()
for x in list_keymaps(kb, include_userspace=False):
if x in defaultish or x.startswith('default'):
keymaps.add(x)
# Ensure that at least a 'default' keymap always exists
keymaps.add('default')
return keymaps
@@ -366,6 +361,11 @@ def lint(cli):
cli.print_help()
return False
# milc config handling of user.keymap breaks running lint without keymap argument
# so we have to disable that while still allowing a default to be set with lint.keymap
if 'keymap' not in cli.config_source.lint.keys() and cli.config.lint.keymap:
cli.config.lint.keymap = None
if isinstance(cli.config.lint.keyboard, str):
# if provided via config - string not array
keyboard_list = [cli.config.lint.keyboard]
@@ -381,12 +381,12 @@ def lint(cli):
# Determine keymaps to also check
if cli.args.keymap == 'all':
keymaps = list_keymaps(kb)
elif cli.args.keymap:
keymaps = {cli.args.keymap}
elif cli.config.lint.keymap:
keymaps = {cli.config.lint.keymap}
else:
keymaps = _list_defaultish_keymaps(kb)
# Ensure that at least a 'default' keymap always exists
keymaps.add('default')
ok = True
+18 -14
View File
@@ -389,7 +389,7 @@ def is_keymap_target(keyboard, keymap):
return False
def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False, include_userspace=True):
def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False, include_userspace=True, include_community=True):
"""List the available keymaps for a keyboard.
Args:
@@ -411,6 +411,9 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa
include_userspace
When set to True, also search userspace for available keymaps
include_community
When set to True, also search community layouts folder for available keymaps
Returns:
a sorted list of valid keymap names.
"""
@@ -434,21 +437,22 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa
kb_path = kb_path.parent
# Check community layouts as a fallback
info = info_json(keyboard)
if include_community:
# Check community layouts as a fallback
info = info_json(keyboard)
community_parents = list(Path('layouts').glob('*/'))
if has_userspace and (Path(QMK_USERSPACE) / "layouts").exists():
community_parents.append(Path(QMK_USERSPACE) / "layouts")
community_parents = list(Path('layouts').glob('*/'))
if has_userspace and (Path(QMK_USERSPACE) / "layouts").exists():
community_parents.append(Path(QMK_USERSPACE) / "layouts")
for community_parent in community_parents:
for layout in info.get("community_layouts", []):
cl_path = community_parent / layout
if cl_path.is_dir():
for keymap in cl_path.iterdir():
if is_keymap_dir(keymap, c, json, additional_files):
keymap = keymap if fullpath else keymap.name
names.add(keymap)
for community_parent in community_parents:
for layout in info.get("community_layouts", []):
cl_path = community_parent / layout
if cl_path.is_dir():
for keymap in cl_path.iterdir():
if is_keymap_dir(keymap, c, json, additional_files):
keymap = keymap if fullpath else keymap.name
names.add(keymap)
return sorted(names)