-
-
Notifications
You must be signed in to change notification settings - Fork 38k
Avoid exception when loading translation file for unloaded module #15765
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,8 @@ def load_json(filename: str, default: Union[List, Dict, None] = None) \ | |
|
|
||
| Defaults to returning empty dict if file is not found. | ||
| """ | ||
| if filename is None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also not good. We should fail. This code should never be called if filename is None. We should write code that doesn't handle "bad" inputs and tries to fix them. Raise errors instead. The moment we fix them, that function will need to keep fixing it forever, even if other things get added to the function that would allow the previously bad input. The previously bad input expects to be "changed" or else bugs in other code happen. |
||
| return {} | ||
| try: | ||
| with open(filename, encoding='utf-8') as fdesc: | ||
| return json.loads(fdesc.read()) # type: ignore | ||
|
|
||
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.
This makes no sense.
get_componentis not about things not being setup. It's about loading the component from file, either from your custom components dir or from built-in.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.
Alright, you are forcing me to fix the root cause. Got it.