-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add type hints and initial Mypy configuration #930
Conversation
Signed-off-by: Thore Sommer <mail@thson.de>
Signed-off-by: Thore Sommer <mail@thson.de>
Signed-off-by: Thore Sommer <mail@thson.de>
Signed-off-by: Thore Sommer <mail@thson.de>
Signed-off-by: Thore Sommer <mail@thson.de>
Signed-off-by: Thore Sommer <mail@thson.de>
_sub_components: Optional[List[str]] | ||
|
||
def __init__(self, component, sub_components=None): | ||
def __init__(self, component: Component, sub_components: Optional[List[str]] = None): |
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.
Just a question on style here: Does the type hints syntax prefer whitespace around the equals sign?
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.
I think so: https://peps.python.org/pep-3107/#parameters.
Overall I like this change as it should prevent some accidental bugs in the future. Being unfamiliar with Mypy, are there any performance considerations? |
Type hints are ignored at runtime, so there should be no performance impact other than the hints are getting parsed and then ignored. |
/packit test |
@kkaarreell why did this e2e CI pass? |
There is some issue with tmt plan on c9s and c8s where prepare steps are replaced, not added. As a result c8s and c9s are run against upstream master. I have just found out few minutes back. |
This PR adds full type hints to:
ima_ast.py
failure.py
algorithms.py
keylime_loggin.py
json.py
I also added a Mypy configuration with
strict
set to true which should enable most of the Mypy checks.Once more parts of Keylime have type hints I will add this to the tox configuration.
Part of #929