-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: development
Are you sure you want to change the base?
Conversation
@@ -67,8 +67,10 @@ def gen_row(row): | |||
|
|||
if plugin_results: | |||
rows = [] | |||
for result in plugin_results: |
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.
Not sure this rename was needed
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.
mypy doesn't like re-use of variable names, I can ignore it if needed
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 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.
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.
updated previous loop to connection_result as well for consistency
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.
looks good, added a few suggestions.
nodescraper/models/event.py
Outdated
@@ -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 |
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 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.
def _compare_cmdline( | ||
self, cmdline: str, required_cmdline: str | list[Any], banned_cmdline: str | list[Any] | ||
) -> bool: |
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.
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.
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.
Adjusted the analyzer args model instead.
b7cf814
to
50255ed
Compare
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.