-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[Scripts - 3] Added types for pylint and docstring_checker #16548
Conversation
Hi @aasiffaizal, can you complete the following:
|
Hi @aasiffaizal please assign the required reviewer(s) for this PR. Thanks! |
# Thus to avoid MyPy's error | ||
# (Class cannot subclass 'BaseChecker' (has type 'Any')), | ||
# we added an ignore here. | ||
class GoogleDocstring(_check_docs_utils.GoogleDocstring): # type: ignore[misc] |
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.
Pylint is partially typed and has the use of many Any
, and hence it throws an error when inheriting any classes from them. Since stubs weren't available and specific stubbing of what we use wasn't also working since mypy doesn't support partial stubbing and can be found over here
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.
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.
Just to close the conversation!
A new issue is created refer: #16548 (comment)
@vojtechjelinek @sahiljoster32 @U8NWXD Could you, please take a look? |
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.
Thanks! Took a pass.
@vojtechjelinek @U8NWXD I've addressed all the comments. Can you PTAL? |
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.
PR looks good just some minor nits, Thanks @aasiffaizal!
scripts/linters/pylint_extensions.py
Outdated
"""Checks whether the object class in a module has been documented | ||
or not. If the object class is not documented then adds an error | ||
message. | ||
|
||
Args: | ||
tokens: Token. Object to access all tokens of a module. | ||
node: astroid.scoped_nodes.Module. Node to access module content. | ||
tokens: List[Token]. Object to access all tokens of a module. |
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.
tokens: List[Token]. Object to access all tokens of a module. | |
tokens: List[TokenInfo]. Object to access all tokens of a module. |
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.
done
scripts/linters/pylint_extensions.py
Outdated
"""Checks whether the Any type in a module has been documented | ||
or not. If the Any type is not documented then adds an error | ||
message. | ||
|
||
Args: | ||
tokens: Token. Object to access all tokens of a module. | ||
node: astroid.scoped_nodes.Module. Node to access module content. | ||
tokens: List[Token]. Object to access all tokens of a module. |
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.
ditto
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.
done
scripts/linters/pylint_extensions.py
Outdated
@@ -2113,7 +2284,13 @@ def _process_module_tokens(self, tokens, node): | |||
'redundant-type-comment', line=comment_line_number, node=node) | |||
|
|||
|
|||
class SingleSpaceAfterKeyWordChecker(checkers.BaseChecker): | |||
# TODO(#15613): Here we use MyPy ignore because of the incomplete typing of |
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.
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.
Yeah my bad. I have created a new issue #16567
@@ -2027,7 +2194,9 @@ def visit_module(self, node): | |||
tokens = pylint_utils.tokenize_module(node) | |||
self._process_module_tokens(tokens, node) | |||
|
|||
def _process_module_tokens(self, tokens, node): | |||
def _process_module_tokens( | |||
self, tokens: List[tokenize.TokenInfo], node: astroid.Module |
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.
Please update the docstring as well.
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.
done
@@ -1486,7 +1603,7 @@ class FunctionArgsOrderChecker(checkers.BaseChecker): | |||
'\'cls\' should come first'), | |||
} | |||
|
|||
def visit_functiondef(self, node): | |||
def visit_functiondef(self, node: astroid.nodes.FunctionDef) -> 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.
please update the docstring with FunctionDef
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.
done
@@ -1348,7 +1437,9 @@ def check_single_constructor_params(self, class_doc, init_doc, class_node): | |||
args=(class_node.name,), | |||
node=class_node) | |||
|
|||
def _handle_no_raise_doc(self, excs, node): | |||
def _handle_no_raise_doc( | |||
self, excs: Set[str], node: astroid.nodes.FunctionDef |
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.
update docstring, please
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.
done
self, | ||
class_doc: _check_docs_utils.Docstring, | ||
init_doc: _check_docs_utils.Docstring, | ||
class_node: astroid.nodes.ClassDef |
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.
Please update docstring!
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.
done
@@ -863,7 +918,9 @@ def check_docstring_structure(self, node): | |||
any(word in docstring[-2] for word in EXCLUDED_PHRASES)): | |||
self.add_message('no-period-used', node=node) | |||
|
|||
def check_docstring_section_indentation(self, node): | |||
def check_docstring_section_indentation( | |||
self, node: astroid.nodes.FunctionDef |
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.
Please update docstring! Function -> FunctionDef
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.
done
def check_functiondef_returns(self, node, node_doc): | ||
def check_functiondef_returns( | ||
self, | ||
node: astroid.nodes.FunctionDef, |
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.
Update docstring Function -> FunctionDef
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.
done
# Thus to avoid MyPy's error | ||
# (Class cannot subclass 'BaseChecker' (has type 'Any')), | ||
# we added an ignore here. | ||
class GoogleDocstring(_check_docs_utils.GoogleDocstring): # type: ignore[misc] |
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.
Unassigning @sahiljoster32 since the review is done. |
Hi @aasiffaizal, it looks like some changes were requested on this pull request by @sahiljoster32. PTAL. Thanks! |
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.
LGTM!
Unassigning @vojtechjelinek since they have already approved the PR. |
@sahiljoster32 Addressed all the comments. Could you PTAL? |
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.
LGTM!, Just one nit!!
Unassigning @sahiljoster32 since they have already approved the PR. |
Hi @aasiffaizal. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks! |
Hi @aasiffaizal, this PR is ready to be merged. Please address any remaining comments prior to merging, and feel free to merge this PR once the CI checks pass and you're happy with it. Thanks! |
Since all the comments are addressed and all the reviewers approved the PR. I'm going to merge this, Thanks @aasiffaizal! |
Overview
scripts/docstrings_checker.py
,scripts/linters/pylint_extensions.py
.Essential Checklist
Proof that changes are correct
Proof of changes on desktop with slow/throttled network
Proof of changes on mobile phone
Proof of changes in Arabic language
PR Pointers