Skip to content

Feature/mypy precommit #6

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

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open

Conversation

sidamd
Copy link
Collaborator

@sidamd sidamd commented Jun 16, 2025

added mypy to pre-commit hooks and dependencies list. Fixed dataanalyzer interface, task.py, event.py, tablesummary.py, and cmd_analyzer.py to pass mypy type checks.

@@ -67,8 +67,10 @@ def gen_row(row):

if plugin_results:
rows = []
for result in plugin_results:
Copy link
Collaborator

@alexandraBara alexandraBara Jun 19, 2025

Choose a reason for hiding this comment

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

Not sure this rename was needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mypy doesn't like re-use of variable names, I can ignore it if needed

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the change is fine in that case, I would maybe suggest just also updating the previous loop as well to be connection_result instead of just result for consistency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated previous loop to connection_result as well for consistency

Copy link
Collaborator

@landrews-amd landrews-amd left a comment

Choose a reason for hiding this comment

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

looks good, added a few suggestions.

@@ -51,7 +51,7 @@ class Event(BaseModel):
default_factory=lambda: datetime.datetime.now(datetime.timezone.utc)
)
reporter: str = "ERROR_SCRAPER"
category: str
category: str | Enum
Copy link
Collaborator

Choose a reason for hiding this comment

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

The type here actually should remain as just string, the validator can accept an enum but it will convert to a string when setting the value. The category attribute of the model will always be a string.

Comment on lines 41 to 43
def _compare_cmdline(
self, cmdline: str, required_cmdline: str | list[Any], banned_cmdline: str | list[Any]
) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

For this I think that we should actually adjust the type for the analyzer args. Right now required_cmdline / banned_cmdline have a type of 'list | str' however the validators will ensure that in fact they are always lists.
We should update the type for the analyzer args model to be just list and then leave the list type here as well since it should then be aligned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adjusted the analyzer args model instead.

@sidamd sidamd force-pushed the feature/mypy-precommit branch from b7cf814 to 50255ed Compare June 20, 2025 17:58
@sidamd sidamd requested a review from landrews-amd June 20, 2025 20:16
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.

3 participants