-
Notifications
You must be signed in to change notification settings - Fork 226
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
Mypy hook #1123
Conversation
jstucke
commented
Sep 1, 2023
•
edited
Loading
edited
- added mypy pre-commit hook
- added mypy config
- fixed all issues in the code base or at least added ignore comments where it wasn't possible
…arison ID type alias
…arison ID type alias
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.
Overall lgtm but still some questions.
src/analysis/plugin/plugin.py
Outdated
"""Analyze a file. | ||
May return None if nothing was found. | ||
|
||
:param file_handle: :py:class:`io.FileIO` instance of the file to be analyzed | ||
:param virtual_file_path: The virtual file paths, see :py:class:`~objects.file.FileObject` | ||
:param analyses: A dictionary of dependent analysis | ||
|
||
:return: The analysis if anything was found. | ||
:return: The analysis results (if there are any). |
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.
nit: why use parentheses?
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.
In general? 😅
I don't know, if you want I can remove them. I originally just wanted to specify that analysis results are returned.
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 meant that what is written in the parentheses is useful information and reads better without the parantheses.
src/analysis/plugin/plugin.py
Outdated
@@ -145,7 +149,7 @@ def get_analysis(self, file_handle: io.FileIO, virtual_file_path: dict, analyses | |||
'system_version': self.metadata.system_version, | |||
'summary': summary, | |||
'tags': tags_dict, | |||
'result': result.dict() if result else None, | |||
'result': result.dict() if isinstance(result, BaseModel) else 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.
Why is this 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 during the time I wasn't sure if the plugin always returns a BaseModel
or if it can be a dict
if no schema is specified. I think as it is now, the schema is mandatory and the plugin always returns a BaseModel
, right?
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.
right?
Exactly!
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 had a brief look at everything but didn't look in depth.
I hope I found any actual code changes and reviewed them.
For the typing changes I'm happy when mypy is.
from multiprocessing import Value | ||
from helperFunctions.types import MpValue, MpArray | ||
|
||
pass |
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.
Typo?
We decided to split this up into smaller PRs to make each one reviewable |