Skip to content
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

Merged
merged 6 commits into from
Mar 22, 2022

Conversation

THS-on
Copy link
Member

@THS-on THS-on commented Mar 21, 2022

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

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):
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpeters
Copy link
Member

mpeters commented Mar 21, 2022

Overall I like this change as it should prevent some accidental bugs in the future. Being unfamiliar with Mypy, are there any performance considerations?

@THS-on
Copy link
Member Author

THS-on commented Mar 21, 2022

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.

@THS-on THS-on mentioned this pull request Mar 22, 2022
39 tasks
@THS-on
Copy link
Member Author

THS-on commented Mar 22, 2022

/packit test

@maugustosilva maugustosilva self-requested a review March 22, 2022 15:35
@mpeters mpeters merged commit e275d0c into keylime:master Mar 22, 2022
@THS-on
Copy link
Member Author

THS-on commented Mar 22, 2022

@kkaarreell why did this e2e CI pass?

@kkaarreell
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants