Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude external userspace from lint checking #24680

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/python/qmk/cli/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _list_defaultish_keymaps(kb):
defaultish.extend(INVALID_KM_NAMES)

keymaps = set()
for x in list_keymaps(kb):
for x in list_keymaps(kb, include_userspace=False):
if x in defaultish or x.startswith('default'):
keymaps.add(x)

Expand Down
11 changes: 8 additions & 3 deletions lib/python/qmk/keymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def is_keymap_target(keyboard, keymap):
return False


def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False):
def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False, include_userspace=True):
"""List the available keymaps for a keyboard.

Args:
Expand All @@ -445,14 +445,19 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa
fullpath
When set to True the full path of the keymap relative to the `qmk_firmware` root will be provided.

include_userspace
When set to True, also search userspace for available keymaps

Returns:
a sorted list of valid keymap names.
"""
names = set()

has_userspace = HAS_QMK_USERSPACE and include_userspace

# walk up the directory tree until keyboards_dir
# and collect all directories' name with keymap.c file in it
for search_dir in [QMK_FIRMWARE, QMK_USERSPACE] if HAS_QMK_USERSPACE else [QMK_FIRMWARE]:
for search_dir in [QMK_FIRMWARE, QMK_USERSPACE] if has_userspace else [QMK_FIRMWARE]:
keyboards_dir = search_dir / Path('keyboards')
kb_path = keyboards_dir / keyboard

Expand All @@ -470,7 +475,7 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa
info = info_json(keyboard)

community_parents = list(Path('layouts').glob('*/'))
if HAS_QMK_USERSPACE and (Path(QMK_USERSPACE) / "layouts").exists():
if has_userspace and (Path(QMK_USERSPACE) / "layouts").exists():
community_parents.append(Path(QMK_USERSPACE) / "layouts")

for community_parent in community_parents:
Expand Down
Loading