From 7e66f453ca4e9164f3bf23f3735ff33a67ae038f Mon Sep 17 00:00:00 2001 From: rsashank Date: Fri, 6 Sep 2024 05:17:34 +0530 Subject: [PATCH] lint-hotkeys: Add linting for HELP_CATEGORIES. - Implemented a linting check to ensure all `key_category` values in `KEY_BINDINGS` are present in the `HELP_CATEGORIES` dictionary. - Added functionality to print any missing categories if they are not found in `HELP_CATEGORIES`. --- tools/lint-hotkeys | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/lint-hotkeys b/tools/lint-hotkeys index 83a7db068e..648b80b0c7 100755 --- a/tools/lint-hotkeys +++ b/tools/lint-hotkeys @@ -30,6 +30,7 @@ def main(fix: bool) -> None: if fix: generate_hotkeys_file() else: + lint_help_categories() lint_hotkeys_file() @@ -80,6 +81,22 @@ def lint_hotkeys_file() -> None: sys.exit(error_flag) +def lint_help_categories() -> None: + """ + Check if HELP_CATEGORIES contains all key categories + """ + missing_categories = [ + binding["key_category"] + for binding in KEY_BINDINGS.values() + if binding["key_category"] not in HELP_CATEGORIES + ] + if missing_categories: + print( + f"Missing categories in HELP_CATEGORIES (keys.py file): {missing_categories}" + ) + sys.exit(1) + + def generate_hotkeys_file() -> None: """ Generate OUTPUT_FILE based on help text description and