-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Lint the validity of help categories #1518
base: main
Are you sure you want to change the base?
Conversation
To check for typos.
d4ad452
to
4afff89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @Niloth-p!
The intention is clear. I've tested this on my PC and reviewed the code, and it LGTM 👍.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a nice idea to check for this and will hopefully improve the developer experience :) Thanks for working on this!
It's a bit adjacent to this PR, but while you're in this area of the code, I've left a comment to improve it. I think it wouldn't hurt to fix it as part of this PR, as it's a very small PR anyways.
I'm still approving it, because in my opinion it's optional to fix.
tools/lint-hotkeys
Outdated
@@ -39,8 +39,8 @@ def lint_hotkeys_file() -> None: | |||
existing OUTPUT_FILE | |||
""" | |||
hotkeys_file_string = get_hotkeys_file_string() | |||
error_flag = 0 if is_every_key_category_valid() else 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's rather independent of this change, but it's quite strange to me to use 0
and 1
instead of a boolean here. I know sys.exit
wants to have an integer, but it should in my opinion only be converted to it at the very last moment.
b02cbe6
to
82dccf2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if key_category not in HELP_CATEGORIES: | ||
print( | ||
f"Invalid key_category '{key_category}' for key '{key}'." | ||
f" Choose a category from:\n{', '.join(HELP_CATEGORIES.keys())}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: For a dev tool this isn't as important, but with this number of categories we already run quite far to the right, so a vertical list may be cleaner to read.
error_flag = True | ||
sys.exit(error_flag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this likely works, an explicit conversion here would be good, as per #1518 (comment)
error_flag = 0 if is_every_key_category_valid() else 1 | ||
error_flag = not is_every_key_category_valid() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: As it's now a boolean, it'd also be useful to have a cleaner name for this.
Maybe is_any_error_present
, or similar.
Thank you for the review, @neiljp. I've actually absorbed these 2 commits into #1484's refactoring. We could finish these here, and I'll have to rebase that branch to make the flow still make sense (I would prefer to avoid that if possible, as it could lead to making silly errors and code degradation in the worst case (like it happened once before with the hotkeys.md)). See |
What does this PR do, and why?
Check for typos in category names.
Previously, these typos would go unnoticed, with the key binding going missing from the help menu.
Outstanding aspect(s)
External discussion & connections
topic
How did you test this?
Self-review checklist for each commit
Visual changes