-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
(feat) Add type annotations checker #10749
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: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Alvaro Frias <[email protected]>
Signed-off-by: Alvaro Frias <[email protected]>
Signed-off-by: Alvaro Frias <[email protected]>
Signed-off-by: Alvaro Frias <[email protected]>
Signed-off-by: Alvaro Frias <[email protected]>
Signed-off-by: Alvaro Frias <[email protected]>
This comment has been minimized.
This comment has been minimized.
Pierre-Sassoulas
left a comment
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.
Thank you for this PR, this looks pretty refined already.
| with ``--enable=missing-return-type-annotation``. | ||
|
|
||
| The check automatically skips: | ||
|
|
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.
Maybe we can also add function and methods starting with test_ for return-type ? I always found adding -> None in all tests to be rather pointless. But then mypy would disagree and we probably want to agree with mypy. (Btw just gave me an idea of a checker to check that function starting with test_ should not return anything).
Signed-off-by: Alvaro Frias <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: Alvaro Frias <[email protected]>
β¦nt into feature/require-typeannotation
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Alvaro Frias <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: Alvaro Frias <[email protected]>
β¦nt into feature/require-typeannotation
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10749 +/- ##
==========================================
+ Coverage 95.98% 95.99% +0.01%
==========================================
Files 176 177 +1
Lines 19540 19623 +83
==========================================
+ Hits 18755 18838 +83
Misses 785 785
π New features to boost your workflow:
|
Signed-off-by: Alvaro Frias <[email protected]>
Signed-off-by: Alvaro Frias <[email protected]>
Type of Changes
Description
This PR implements a new type annotation checker for Pylint that helps enforce the presence of type annotations in Python code. As discussed in #3853, type annotations improve code readability and enable better static analysis.
What's New
Two New Convention-Level Checkers
C2901:
missing-return-type-annotationDetects functions and methods without return type annotations.
C2902:
missing-param-type-annotationDetects function/method parameters without type annotations.
Key Features
*args,**kwargs)selfandclsparameters (automatically skipped)__init__methods (return type check skipped)@abstractmethod,@propertydecorators@typing.overloadstub definitionsFuture Enhancements
Following Issue discussion and the Google Python Style Guide model, which requires annotations only for public APIs, it could be added different checks for private/public methods:
Other possible future enhancements can be Variable Annotations, and configurable options in .pylintrc
Closes #3853