fname
stringlengths
63
176
rel_fname
stringclasses
706 values
line
int64
-1
4.5k
name
stringlengths
1
81
kind
stringclasses
2 values
category
stringclasses
2 values
info
stringlengths
0
77.9k
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/consider_ternary_expression.py
pylint/extensions/consider_ternary_expression.py
48
add_message
ref
function
self.add_message("consider-ternary-expression", node=node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/consider_ternary_expression.py
pylint/extensions/consider_ternary_expression.py
51
register
def
function
def register(linter: "PyLinter") -> None: linter.register_checker(ConsiderTernaryExpressionChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/consider_ternary_expression.py
pylint/extensions/consider_ternary_expression.py
52
register_checker
ref
function
linter.register_checker(ConsiderTernaryExpressionChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/consider_ternary_expression.py
pylint/extensions/consider_ternary_expression.py
52
ConsiderTernaryExpressionChecker
ref
function
linter.register_checker(ConsiderTernaryExpressionChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
44
DocstringParameterChecker
def
class
visit_functiondef check_functiondef_params check_functiondef_returns check_functiondef_yields visit_raise visit_return visit_yield visit_yieldfrom _compare_missing_args _compare_different_args _compare_ignored_args check_arguments_in_docstring check_single_constructor_params _handle_no_raise_doc _add_raise_message
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
215
visit_functiondef
def
function
def visit_functiondef(self, node: nodes.FunctionDef) -> None: """Called for function and method definitions (def). :param node: Node for a function or method definition in the AST :type node: :class:`astroid.scoped_nodes.Function` """ node_doc = utils.docstringify(node.doc, self.config.default_docstring_type) # skip functions that match the 'no-docstring-rgx' config option no_docstring_rgx = get_global_option(self, "no-docstring-rgx") if no_docstring_rgx and re.match(no_docstring_rgx, node.name): return # skip functions smaller than 'docstring-min-length' lines = checker_utils.get_node_last_lineno(node) - node.lineno max_lines = get_global_option(self, "docstring-min-length") if max_lines > -1 and lines < max_lines: return self.check_functiondef_params(node, node_doc) self.check_functiondef_returns(node, node_doc) self.check_functiondef_yields(node, node_doc) visit_asyncfunctiondef = visit_functiondef def check_functiondef_params(self, node, node_doc): node_allow_no_param = None if node.name in self.constructor_names: class_node = checker_utils.node_frame_class(node) if class_node is not None: class_doc = utils.docstringify( class_node.doc, self.config.default_docstring_type ) self.check_single_constructor_params(class_doc, node_doc, class_node) # __init__ or class docstrings can have no parameters documented # as long as the other documents them. node_allow_no_param = ( class_doc.has_params() or class_doc.params_documented_elsewhere() or None ) class_allow_no_param = ( node_doc.has_params() or node_doc.params_documented_elsewhere() or None ) self.check_arguments_in_docstring( class_doc, node.args, class_node, class_allow_no_param ) self.check_arguments_in_docstring( node_doc, node.args, node, node_allow_no_param ) def check_functiondef_returns(self, node, node_doc): if (not node_doc.supports_yields and node.is_generator()) or node.is_abstract(): return return_nodes = node.nodes_of_class(astroid.Return) if (node_doc.has_returns() or node_doc.has_rtype()) and not any( utils.returns_something(ret_node) for ret_node in return_nodes ): self.add_message("redundant-returns-doc", node=node) def check_functiondef_yields(self, node, node_doc): if not node_doc.supports_yields or node.is_abstract(): return if ( node_doc.has_yields() or node_doc.has_yields_type() ) and not node.is_generator(): self.add_message("redundant-yields-doc", node=node) def visit_raise(self, node: nodes.Raise) -> None: func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return expected_excs = utils.possible_exc_types(node) if not expected_excs: return if not func_node.doc: # If this is a property setter, # the property should have the docstring instead. property_ = utils.get_setters_property(func_node) if property_: func_node = property_ doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if not doc.matching_sections(): if doc.doc: missing = {exc.name for exc in expected_excs} self._handle_no_raise_doc(missing, func_node) return found_excs_full_names = doc.exceptions() # Extract just the class name, e.g. "error" from "re.error" found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names} missing_excs = set() for expected in expected_excs: for found_exc in found_excs_class_names: if found_exc == expected.name: break if any(found_exc == ancestor.name for ancestor in expected.ancestors()): break else: missing_excs.add(expected.name) self._add_raise_message(missing_excs, func_node) def visit_return(self, node: nodes.Return) -> None: if not utils.returns_something(node): return if self.config.accept_no_return_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) is_property = checker_utils.decorated_with_property(func_node) if not (doc.has_returns() or (doc.has_property_returns() and is_property)): self.add_message("missing-return-doc", node=func_node) if func_node.returns: return if not (doc.has_rtype() or (doc.has_property_type() and is_property)): self.add_message("missing-return-type-doc", node=func_node) def visit_yield(self, node: nodes.Yield) -> None: if self.config.accept_no_yields_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if doc.supports_yields: doc_has_yields = doc.has_yields() doc_has_yields_type = doc.has_yields_type() else: doc_has_yields = doc.has_returns() doc_has_yields_type = doc.has_rtype() if not doc_has_yields: self.add_message("missing-yield-doc", node=func_node) if not (doc_has_yields_type or func_node.returns): self.add_message("missing-yield-type-doc", node=func_node) def visit_yieldfrom(self, node: nodes.YieldFrom) -> None: self.visit_yield(node) def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
221
docstringify
ref
function
node_doc = utils.docstringify(node.doc, self.config.default_docstring_type)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
224
get_global_option
ref
function
no_docstring_rgx = get_global_option(self, "no-docstring-rgx")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
229
get_node_last_lineno
ref
function
lines = checker_utils.get_node_last_lineno(node) - node.lineno
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
230
get_global_option
ref
function
max_lines = get_global_option(self, "docstring-min-length")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
234
check_functiondef_params
ref
function
self.check_functiondef_params(node, node_doc)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
235
check_functiondef_returns
ref
function
self.check_functiondef_returns(node, node_doc)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
236
check_functiondef_yields
ref
function
self.check_functiondef_yields(node, node_doc)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
240
check_functiondef_params
def
function
def check_functiondef_params(self, node, node_doc): node_allow_no_param = None if node.name in self.constructor_names: class_node = checker_utils.node_frame_class(node) if class_node is not None: class_doc = utils.docstringify( class_node.doc, self.config.default_docstring_type ) self.check_single_constructor_params(class_doc, node_doc, class_node) # __init__ or class docstrings can have no parameters documented # as long as the other documents them. node_allow_no_param = ( class_doc.has_params() or class_doc.params_documented_elsewhere() or None ) class_allow_no_param = ( node_doc.has_params() or node_doc.params_documented_elsewhere() or None ) self.check_arguments_in_docstring( class_doc, node.args, class_node, class_allow_no_param ) self.check_arguments_in_docstring( node_doc, node.args, node, node_allow_no_param ) def check_functiondef_returns(self, node, node_doc): if (not node_doc.supports_yields and node.is_generator()) or node.is_abstract(): return return_nodes = node.nodes_of_class(astroid.Return) if (node_doc.has_returns() or node_doc.has_rtype()) and not any( utils.returns_something(ret_node) for ret_node in return_nodes ): self.add_message("redundant-returns-doc", node=node) def check_functiondef_yields(self, node, node_doc): if not node_doc.supports_yields or node.is_abstract(): return if ( node_doc.has_yields() or node_doc.has_yields_type() ) and not node.is_generator(): self.add_message("redundant-yields-doc", node=node) def visit_raise(self, node: nodes.Raise) -> None: func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return expected_excs = utils.possible_exc_types(node) if not expected_excs: return if not func_node.doc: # If this is a property setter, # the property should have the docstring instead. property_ = utils.get_setters_property(func_node) if property_: func_node = property_ doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if not doc.matching_sections(): if doc.doc: missing = {exc.name for exc in expected_excs} self._handle_no_raise_doc(missing, func_node) return found_excs_full_names = doc.exceptions() # Extract just the class name, e.g. "error" from "re.error" found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names} missing_excs = set() for expected in expected_excs: for found_exc in found_excs_class_names: if found_exc == expected.name: break if any(found_exc == ancestor.name for ancestor in expected.ancestors()): break else: missing_excs.add(expected.name) self._add_raise_message(missing_excs, func_node) def visit_return(self, node: nodes.Return) -> None: if not utils.returns_something(node): return if self.config.accept_no_return_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) is_property = checker_utils.decorated_with_property(func_node) if not (doc.has_returns() or (doc.has_property_returns() and is_property)): self.add_message("missing-return-doc", node=func_node) if func_node.returns: return if not (doc.has_rtype() or (doc.has_property_type() and is_property)): self.add_message("missing-return-type-doc", node=func_node) def visit_yield(self, node: nodes.Yield) -> None: if self.config.accept_no_yields_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if doc.supports_yields: doc_has_yields = doc.has_yields() doc_has_yields_type = doc.has_yields_type() else: doc_has_yields = doc.has_returns() doc_has_yields_type = doc.has_rtype() if not doc_has_yields: self.add_message("missing-yield-doc", node=func_node) if not (doc_has_yields_type or func_node.returns): self.add_message("missing-yield-type-doc", node=func_node) def visit_yieldfrom(self, node: nodes.YieldFrom) -> None: self.visit_yield(node) def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
243
node_frame_class
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
245
docstringify
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
248
check_single_constructor_params
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
253
has_params
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
254
params_documented_elsewhere
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
258
has_params
ref
function
node_doc.has_params()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
259
params_documented_elsewhere
ref
function
or node_doc.params_documented_elsewhere()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
263
check_arguments_in_docstring
ref
function
self.check_arguments_in_docstring(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
267
check_arguments_in_docstring
ref
function
self.check_arguments_in_docstring(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
271
check_functiondef_returns
def
function
def check_functiondef_returns(self, node, node_doc): if (not node_doc.supports_yields and node.is_generator()) or node.is_abstract(): return return_nodes = node.nodes_of_class(astroid.Return) if (node_doc.has_returns() or node_doc.has_rtype()) and not any( utils.returns_something(ret_node) for ret_node in return_nodes ): self.add_message("redundant-returns-doc", node=node) def check_functiondef_yields(self, node, node_doc): if not node_doc.supports_yields or node.is_abstract(): return if ( node_doc.has_yields() or node_doc.has_yields_type() ) and not node.is_generator(): self.add_message("redundant-yields-doc", node=node) def visit_raise(self, node: nodes.Raise) -> None: func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return expected_excs = utils.possible_exc_types(node) if not expected_excs: return if not func_node.doc: # If this is a property setter, # the property should have the docstring instead. property_ = utils.get_setters_property(func_node) if property_: func_node = property_ doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if not doc.matching_sections(): if doc.doc: missing = {exc.name for exc in expected_excs} self._handle_no_raise_doc(missing, func_node) return found_excs_full_names = doc.exceptions() # Extract just the class name, e.g. "error" from "re.error" found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names} missing_excs = set() for expected in expected_excs: for found_exc in found_excs_class_names: if found_exc == expected.name: break if any(found_exc == ancestor.name for ancestor in expected.ancestors()): break else: missing_excs.add(expected.name) self._add_raise_message(missing_excs, func_node) def visit_return(self, node: nodes.Return) -> None: if not utils.returns_something(node): return if self.config.accept_no_return_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) is_property = checker_utils.decorated_with_property(func_node) if not (doc.has_returns() or (doc.has_property_returns() and is_property)): self.add_message("missing-return-doc", node=func_node) if func_node.returns: return if not (doc.has_rtype() or (doc.has_property_type() and is_property)): self.add_message("missing-return-type-doc", node=func_node) def visit_yield(self, node: nodes.Yield) -> None: if self.config.accept_no_yields_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if doc.supports_yields: doc_has_yields = doc.has_yields() doc_has_yields_type = doc.has_yields_type() else: doc_has_yields = doc.has_returns() doc_has_yields_type = doc.has_rtype() if not doc_has_yields: self.add_message("missing-yield-doc", node=func_node) if not (doc_has_yields_type or func_node.returns): self.add_message("missing-yield-type-doc", node=func_node) def visit_yieldfrom(self, node: nodes.YieldFrom) -> None: self.visit_yield(node) def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
272
is_generator
ref
function
if (not node_doc.supports_yields and node.is_generator()) or node.is_abstract():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
272
is_abstract
ref
function
if (not node_doc.supports_yields and node.is_generator()) or node.is_abstract():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
275
nodes_of_class
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
276
has_returns
ref
function
if (node_doc.has_returns() or node_doc.has_rtype()) and not any(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
276
has_rtype
ref
function
if (node_doc.has_returns() or node_doc.has_rtype()) and not any(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
277
returns_something
ref
function
utils.returns_something(ret_node) for ret_node in return_nodes
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
279
add_message
ref
function
self.add_message("redundant-returns-doc", node=node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
281
check_functiondef_yields
def
function
def check_functiondef_yields(self, node, node_doc): if not node_doc.supports_yields or node.is_abstract(): return if ( node_doc.has_yields() or node_doc.has_yields_type() ) and not node.is_generator(): self.add_message("redundant-yields-doc", node=node) def visit_raise(self, node: nodes.Raise) -> None: func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return expected_excs = utils.possible_exc_types(node) if not expected_excs: return if not func_node.doc: # If this is a property setter, # the property should have the docstring instead. property_ = utils.get_setters_property(func_node) if property_: func_node = property_ doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if not doc.matching_sections(): if doc.doc: missing = {exc.name for exc in expected_excs} self._handle_no_raise_doc(missing, func_node) return found_excs_full_names = doc.exceptions() # Extract just the class name, e.g. "error" from "re.error" found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names} missing_excs = set() for expected in expected_excs: for found_exc in found_excs_class_names: if found_exc == expected.name: break if any(found_exc == ancestor.name for ancestor in expected.ancestors()): break else: missing_excs.add(expected.name) self._add_raise_message(missing_excs, func_node) def visit_return(self, node: nodes.Return) -> None: if not utils.returns_something(node): return if self.config.accept_no_return_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) is_property = checker_utils.decorated_with_property(func_node) if not (doc.has_returns() or (doc.has_property_returns() and is_property)): self.add_message("missing-return-doc", node=func_node) if func_node.returns: return if not (doc.has_rtype() or (doc.has_property_type() and is_property)): self.add_message("missing-return-type-doc", node=func_node) def visit_yield(self, node: nodes.Yield) -> None: if self.config.accept_no_yields_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if doc.supports_yields: doc_has_yields = doc.has_yields() doc_has_yields_type = doc.has_yields_type() else: doc_has_yields = doc.has_returns() doc_has_yields_type = doc.has_rtype() if not doc_has_yields: self.add_message("missing-yield-doc", node=func_node) if not (doc_has_yields_type or func_node.returns): self.add_message("missing-yield-type-doc", node=func_node) def visit_yieldfrom(self, node: nodes.YieldFrom) -> None: self.visit_yield(node) def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
282
is_abstract
ref
function
if not node_doc.supports_yields or node.is_abstract():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
286
has_yields
ref
function
node_doc.has_yields() or node_doc.has_yields_type()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
286
has_yields_type
ref
function
node_doc.has_yields() or node_doc.has_yields_type()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
287
is_generator
ref
function
) and not node.is_generator():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
288
add_message
ref
function
self.add_message("redundant-yields-doc", node=node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
290
visit_raise
def
function
def visit_raise(self, node: nodes.Raise) -> None: func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return expected_excs = utils.possible_exc_types(node) if not expected_excs: return if not func_node.doc: # If this is a property setter, # the property should have the docstring instead. property_ = utils.get_setters_property(func_node) if property_: func_node = property_ doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if not doc.matching_sections(): if doc.doc: missing = {exc.name for exc in expected_excs} self._handle_no_raise_doc(missing, func_node) return found_excs_full_names = doc.exceptions() # Extract just the class name, e.g. "error" from "re.error" found_excs_class_names = {exc.split(".")[-1] for exc in found_excs_full_names} missing_excs = set() for expected in expected_excs: for found_exc in found_excs_class_names: if found_exc == expected.name: break if any(found_exc == ancestor.name for ancestor in expected.ancestors()): break else: missing_excs.add(expected.name) self._add_raise_message(missing_excs, func_node) def visit_return(self, node: nodes.Return) -> None: if not utils.returns_something(node): return if self.config.accept_no_return_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) is_property = checker_utils.decorated_with_property(func_node) if not (doc.has_returns() or (doc.has_property_returns() and is_property)): self.add_message("missing-return-doc", node=func_node) if func_node.returns: return if not (doc.has_rtype() or (doc.has_property_type() and is_property)): self.add_message("missing-return-type-doc", node=func_node) def visit_yield(self, node: nodes.Yield) -> None: if self.config.accept_no_yields_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if doc.supports_yields: doc_has_yields = doc.has_yields() doc_has_yields_type = doc.has_yields_type() else: doc_has_yields = doc.has_returns() doc_has_yields_type = doc.has_rtype() if not doc_has_yields: self.add_message("missing-yield-doc", node=func_node) if not (doc_has_yields_type or func_node.returns): self.add_message("missing-yield-type-doc", node=func_node) def visit_yieldfrom(self, node: nodes.YieldFrom) -> None: self.visit_yield(node) def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
291
frame
ref
function
func_node = node.frame(future=True)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
295
possible_exc_types
ref
function
expected_excs = utils.possible_exc_types(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
303
get_setters_property
ref
function
property_ = utils.get_setters_property(func_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
307
docstringify
ref
function
doc = utils.docstringify(func_node.doc, self.config.default_docstring_type)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
308
matching_sections
ref
function
if not doc.matching_sections():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
311
_handle_no_raise_doc
ref
function
self._handle_no_raise_doc(missing, func_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
314
exceptions
ref
function
found_excs_full_names = doc.exceptions()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
324
ancestors
ref
function
if any(found_exc == ancestor.name for ancestor in expected.ancestors()):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
329
_add_raise_message
ref
function
self._add_raise_message(missing_excs, func_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
331
visit_return
def
function
def visit_return(self, node: nodes.Return) -> None: if not utils.returns_something(node): return if self.config.accept_no_return_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) is_property = checker_utils.decorated_with_property(func_node) if not (doc.has_returns() or (doc.has_property_returns() and is_property)): self.add_message("missing-return-doc", node=func_node) if func_node.returns: return if not (doc.has_rtype() or (doc.has_property_type() and is_property)): self.add_message("missing-return-type-doc", node=func_node) def visit_yield(self, node: nodes.Yield) -> None: if self.config.accept_no_yields_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if doc.supports_yields: doc_has_yields = doc.has_yields() doc_has_yields_type = doc.has_yields_type() else: doc_has_yields = doc.has_returns() doc_has_yields_type = doc.has_rtype() if not doc_has_yields: self.add_message("missing-yield-doc", node=func_node) if not (doc_has_yields_type or func_node.returns): self.add_message("missing-yield-type-doc", node=func_node) def visit_yieldfrom(self, node: nodes.YieldFrom) -> None: self.visit_yield(node) def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
332
returns_something
ref
function
if not utils.returns_something(node):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
338
frame
ref
function
func_node = node.frame(future=True)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
342
docstringify
ref
function
doc = utils.docstringify(func_node.doc, self.config.default_docstring_type)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
344
decorated_with_property
ref
function
is_property = checker_utils.decorated_with_property(func_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
346
has_returns
ref
function
if not (doc.has_returns() or (doc.has_property_returns() and is_property)):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
346
has_property_returns
ref
function
if not (doc.has_returns() or (doc.has_property_returns() and is_property)):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
347
add_message
ref
function
self.add_message("missing-return-doc", node=func_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
352
has_rtype
ref
function
if not (doc.has_rtype() or (doc.has_property_type() and is_property)):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
352
has_property_type
ref
function
if not (doc.has_rtype() or (doc.has_property_type() and is_property)):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
353
add_message
ref
function
self.add_message("missing-return-type-doc", node=func_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
355
visit_yield
def
function
def visit_yield(self, node: nodes.Yield) -> None: if self.config.accept_no_yields_doc: return func_node = node.frame(future=_True) if not isinstance(func_node, astroid.FunctionDef): return doc = utils.docstringify(func_node.doc, self.config.default_docstring_type) if doc.supports_yields: doc_has_yields = doc.has_yields() doc_has_yields_type = doc.has_yields_type() else: doc_has_yields = doc.has_returns() doc_has_yields_type = doc.has_rtype() if not doc_has_yields: self.add_message("missing-yield-doc", node=func_node) if not (doc_has_yields_type or func_node.returns): self.add_message("missing-yield-type-doc", node=func_node) def visit_yieldfrom(self, node: nodes.YieldFrom) -> None: self.visit_yield(node) def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
359
frame
ref
function
func_node = node.frame(future=True)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
363
docstringify
ref
function
doc = utils.docstringify(func_node.doc, self.config.default_docstring_type)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
366
has_yields
ref
function
doc_has_yields = doc.has_yields()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
367
has_yields_type
ref
function
doc_has_yields_type = doc.has_yields_type()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
369
has_returns
ref
function
doc_has_yields = doc.has_returns()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
370
has_rtype
ref
function
doc_has_yields_type = doc.has_rtype()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
373
add_message
ref
function
self.add_message("missing-yield-doc", node=func_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
376
add_message
ref
function
self.add_message("missing-yield-type-doc", node=func_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
378
visit_yieldfrom
def
function
def visit_yieldfrom(self, node: nodes.YieldFrom) -> None: self.visit_yield(node) def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
379
visit_yield
ref
function
self.visit_yield(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
381
_compare_missing_args
def
function
def _compare_missing_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are arguments missing. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ missing_argument_names = ( expected_argument_names - found_argument_names ) - not_needed_names if missing_argument_names: self.add_message( message_id, args=(", ".join(sorted(missing_argument_names)),), node=warning_node, ) def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
411
add_message
ref
function
self.add_message(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
417
_compare_different_args
def
function
def _compare_different_args( self, found_argument_names, message_id, not_needed_names, expected_argument_names, warning_node, ): """Compare the found argument names with the expected ones and generate a message if there are extra arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param not_needed_names: names that may be omitted :type not_needed_names: set :param expected_argument_names: Expected argument names :type expected_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ differing_argument_names = ( (expected_argument_names ^ found_argument_names) - not_needed_names - expected_argument_names ) if differing_argument_names: self.add_message( message_id, args=(", ".join(sorted(differing_argument_names)),), node=warning_node, ) def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
450
add_message
ref
function
self.add_message(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
456
_compare_ignored_args
def
function
def _compare_ignored_args( self, found_argument_names, message_id, ignored_argument_names, warning_node, ): """Compare the found argument names with the ignored ones and generate a message if there are ignored arguments found. :param found_argument_names: argument names found in the docstring :type found_argument_names: set :param message_id: pylint message id :type message_id: str :param ignored_argument_names: Expected argument names :type ignored_argument_names: set :param warning_node: The node to be analyzed :type warning_node: :class:`astroid.scoped_nodes.Node` """ existing_ignored_argument_names = ignored_argument_names & found_argument_names if existing_ignored_argument_names: self.add_message( message_id, args=(", ".join(sorted(existing_ignored_argument_names)),), node=warning_node, ) def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
481
add_message
ref
function
self.add_message(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
487
check_arguments_in_docstring
def
function
def check_arguments_in_docstring( self, doc: Docstring, arguments_node: astroid.Arguments, warning_node: astroid.NodeNG, accept_no_param_doc: Optional[bool] = None, ): """Check that all parameters in a function, method or class constructor on the one hand and the parameters mentioned in the parameter documentation (e.g. the Sphinx tags 'param' and 'type') on the other hand are consistent with each other. * Undocumented parameters except 'self' are noticed. * Undocumented parameter types except for 'self' and the ``*<args>`` and ``**<kwargs>`` parameters are noticed. * Parameters mentioned in the parameter documentation that don't or no longer exist in the function parameter list are noticed. * If the text "For the parameters, see" or "For the other parameters, see" (ignoring additional whitespace) is mentioned in the docstring, missing parameter documentation is tolerated. * If there's no Sphinx style, Google style or NumPy style parameter documentation at all, i.e. ``:param`` is never mentioned etc., the checker assumes that the parameters are documented in another format and the absence is tolerated. :param doc: Docstring for the function, method or class. :type doc: :class:`Docstring` :param arguments_node: Arguments node for the function, method or class constructor. :type arguments_node: :class:`astroid.scoped_nodes.Arguments` :param warning_node: The node to assign the warnings to :type warning_node: :class:`astroid.scoped_nodes.Node` :param accept_no_param_doc: Whether to allow no parameters to be documented. If None then this value is read from the configuration. :type accept_no_param_doc: bool or None """ # Tolerate missing param or type declarations if there is a link to # another method carrying the same name. if not doc.doc: return if accept_no_param_doc is None: accept_no_param_doc = self.config.accept_no_param_doc tolerate_missing_params = doc.params_documented_elsewhere() # Collect the function arguments. expected_argument_names = {arg.name for arg in arguments_node.args} expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs) not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy() expected_but_ignored_argument_names = set() ignored_argument_names = get_global_option(self, "ignored-argument-names") if ignored_argument_names: expected_but_ignored_argument_names = { arg for arg in expected_argument_names if ignored_argument_names.match(arg) } if arguments_node.vararg is not None: expected_argument_names.add(f"*{arguments_node.vararg}") not_needed_type_in_docstring.add(f"*{arguments_node.vararg}") if arguments_node.kwarg is not None: expected_argument_names.add(f"**{arguments_node.kwarg}") not_needed_type_in_docstring.add(f"**{arguments_node.kwarg}") params_with_doc, params_with_type = doc.match_param_docs() # Tolerate no parameter documentation at all. if not params_with_doc and not params_with_type and accept_no_param_doc: tolerate_missing_params = _True # This is before the update of param_with_type because this must check only # the type documented in a docstring, not the one using pep484 # See #4117 and #4593 self._compare_ignored_args( params_with_type, "useless-type-doc", expected_but_ignored_argument_names, warning_node, ) for index, arg_name in enumerate(arguments_node.args): if arguments_node.annotations[index]: params_with_type.add(arg_name.name) for index, arg_name in enumerate(arguments_node.kwonlyargs): if arguments_node.kwonlyargs_annotations[index]: params_with_type.add(arg_name.name) if not tolerate_missing_params: missing_param_doc = (expected_argument_names - params_with_doc) - ( self.not_needed_param_in_docstring | expected_but_ignored_argument_names ) missing_type_doc = (expected_argument_names - params_with_type) - ( not_needed_type_in_docstring | expected_but_ignored_argument_names ) if ( missing_param_doc == expected_argument_names == missing_type_doc and len(expected_argument_names) != 0 ): self.add_message( "missing-any-param-doc", args=(warning_node.name,), node=warning_node, ) else: self._compare_missing_args( params_with_doc, "missing-param-doc", self.not_needed_param_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_missing_args( params_with_type, "missing-type-doc", not_needed_type_in_docstring | expected_but_ignored_argument_names, expected_argument_names, warning_node, ) self._compare_different_args( params_with_doc, "differing-param-doc", self.not_needed_param_in_docstring, expected_argument_names, warning_node, ) self._compare_different_args( params_with_type, "differing-type-doc", not_needed_type_in_docstring, expected_argument_names, warning_node, ) self._compare_ignored_args( params_with_doc, "useless-param-doc", expected_but_ignored_argument_names, warning_node, ) def check_single_constructor_params(self, class_doc, init_doc, class_node): if class_doc.has_params() and init_doc.has_params(): self.add_message( "multiple-constructor-doc", args=(class_node.name,), node=class_node ) def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
533
params_documented_elsewhere
ref
function
tolerate_missing_params = doc.params_documented_elsewhere()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
541
get_global_option
ref
function
ignored_argument_names = get_global_option(self, "ignored-argument-names")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
555
match_param_docs
ref
function
params_with_doc, params_with_type = doc.match_param_docs()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
563
_compare_ignored_args
ref
function
self._compare_ignored_args(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
587
add_message
ref
function
self.add_message(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
593
_compare_missing_args
ref
function
self._compare_missing_args(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
601
_compare_missing_args
ref
function
self._compare_missing_args(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
609
_compare_different_args
ref
function
self._compare_different_args(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
616
_compare_different_args
ref
function
self._compare_different_args(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
623
_compare_ignored_args
ref
function
self._compare_ignored_args(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
630
check_single_constructor_params
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
631
has_params
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
631
has_params
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
632
add_message
ref
function
self.add_message(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
636
_handle_no_raise_doc
def
function
def _handle_no_raise_doc(self, excs, node): if self.config.accept_no_raise_doc: return self._add_raise_message(excs, node) def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
640
_add_raise_message
ref
function
self._add_raise_message(excs, node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
642
_add_raise_message
def
function
def _add_raise_message(self, missing_excs, node): """Adds a message on :param:`node` for the missing exception type. :param missing_excs: A list of missing exception types. :type missing_excs: set(str) :param node: The node show the message on. :type node: nodes.NodeNG """ if node.is_abstract(): try: missing_excs.remove("NotImplementedError") except KeyError: pass if not missing_excs: return self.add_message( "missing-raises-doc", args=(", ".join(sorted(missing_excs)),), node=node )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
651
is_abstract
ref
function
if node.is_abstract():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
660
add_message
ref
function
self.add_message(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
665
register
def
function
def register(linter: "PyLinter") -> None: linter.register_checker(DocstringParameterChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
666
register_checker
ref
function
linter.register_checker(DocstringParameterChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docparams.py
pylint/extensions/docparams.py
666
DocstringParameterChecker
ref
function
linter.register_checker(DocstringParameterChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docstyle.py
pylint/extensions/docstyle.py
26
DocStringStyleChecker
def
class
visit_module visit_classdef visit_functiondef _check_docstring
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/extensions/docstyle.py
pylint/extensions/docstyle.py
46
check_messages
ref
function
@check_messages("docstring-first-line-empty", "bad-docstring-quotes")