-
Notifications
You must be signed in to change notification settings - Fork 506
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
refactor: add type hints in util.py #1572
Conversation
07f9ea3
to
0f4908b
Compare
Changed the latest commit message to follow Conventional Commits. |
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.
We definitely should add type checking to CI and pre-commit, it'll make reviewing and adding type hints easier.
@rhythmrx9, oh, where did you want to use it? I'm not super familiar with the concept. |
Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
I wanted to use it for class variables like this, class Sample:
x: ClassVar[int] But now thinking back, and looking at your suggestions, I think it's not needed. |
Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
class CVEData(defaultdict): | ||
def __missing__(self, key): | ||
class CVEData(DefaultDict[str, Union[List[CVE], Set[str]]]): | ||
def __missing__(self, key: str) -> list[CVE] | set[str]: |
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.
Should this one have a return type? I'm not sure if those are needed for __ functions.
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.
We do already use type hints for __ functions, I think we should have them, to be consistent.
This is looking good. I've approved CI to run. I don't think we need to use ClassVar at this time. And I agree that we should probably put some type checking CI stuff in place to make reviewing these easier. If anyone's got a preferred solution for that, let me know. |
Codecov Report
@@ Coverage Diff @@
## main #1572 +/- ##
==========================================
- Coverage 80.36% 80.30% -0.06%
==========================================
Files 281 281
Lines 5581 5590 +9
Branches 913 916 +3
==========================================
+ Hits 4485 4489 +4
- Misses 897 900 +3
- Partials 199 201 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
* related to intel#1539 * refactor: type hints in util.py * refactor: arguments to new __new__ Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com> * refactor: CVEData Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com> * refactor: simplifying type hints Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com> * refactor: type hints in regex_find Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com> * refactor: imports in util.py Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com> * refactor: simplifying type hints Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com> * refactor: simplifying type hints Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com> * refactor: improving type hints in util.py * fix: inline type hints Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com> * fix: imports for inline type hints Co-authored-by: Dmitry Volodin <mr.molkree@gmail.com>
part of #1539
Most of the file already had type hints.
@terriko I did not use ClassVar for class variables as it wasn't already used, Should I add it?