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
Python: fix errors found by type checker #1205
base: master
Are you sure you want to change the base?
Conversation
ebe72ab
to
d51f5b6
Compare
Signed-off-by: Axel Heider <axelheider@gmx.de>
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.
The commit comments can be improved with explanations for the emtpy ones and fixed typos.
@@ -189,7 +189,7 @@ def create_c_header_file(config, kernel_irqs: List, kernel_macros: Dict, | |||
kernel_regions: List, physBase: int, physical_memory, | |||
outputStream): | |||
|
|||
jinja_env = jinja2.Environment(loader=jinja2.BaseLoader, trim_blocks=True, | |||
jinja_env = jinja2.Environment(loader=jinja2.BaseLoader(), trim_blocks=True, |
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.
Surely BaseLoader
is the default, why pass it at all?
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.
Good point, I just fixed the warning here. Explicitly setting this parameter might come from history following recommendations from older versions. Will have a look into this.
tools/hardware/fdt.py
Outdated
node = self.get_path(path) | ||
if node is not None: | ||
ret.append(node) | ||
|
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.
How can this return None?
Also, empty line added unnecessarily.
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.
The static type annotation checker reported this based on the signatures. In this PR I left out addressing the semantics also.
tools/hardware/utils/cpu.py
Outdated
if cpus_node is None: | ||
return [] | ||
|
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 seems better if get_path
returns an empty array than checking for None
everywhere...
Removing the function because it is not use anywhere. Not cloning the owner seems an inconsistent behavior anyway. Signed-off-by: Axel Heider <axelheider@gmx.de>
Support comparisson operations for derived objects only, and fail for anything else. Currently there is no use case that requires duck typing and stricter type checking allows catching potential errors. Signed-off-by: Axel Heider <axelheider@gmx.de>
Signed-off-by: Axel Heider <axelheider@gmx.de>
Signed-off-by: Axel Heider <axelheider@gmx.de>
Signed-off-by: Axel Heider <axelheider@gmx.de>
The DTB appears broken if an item in the chosen node can't be resolved. Raise an error instead of silently ignoring this, as it might be a typo that must be fixed. Otherwise, non-existing items should be removed from the chosen node in a overlay file. Signed-off-by: Axel Heider <axelheider@gmx.de>
The return values is not used by any known callers of this function. There is no sane generic way to handle return values on recursive invocations, thus any visitor must handle this internally. This is doable in Python easily, so there is no need for an additional explicit context parameter either. Signed-off-by: Axel Heider <axelheider@gmx.de>
Element 0 may not exist if the string is empty. Signed-off-by: Axel Heider <axelheider@gmx.de>
Lists are ordered and enumerate() provides the index. Signed-off-by: Axel Heider <axelheider@gmx.de>
Fix errors found by type checker while working on #797