class documentation

Basic checker. Checks for : * doc strings * number of arguments, local variables, branches, returns and statements in functions, methods * required module attributes * dangerous default values as arguments * redefinition of function / method / class * uses of the global statement

Method __init__ Checker instances should have the linter as argument.
Method leave_tryfinally Update try...finally flag.
Method open Initialize visit variables and statistics.
Method visit_assert Check whether assert is used on a tuple or string literal.
Method visit_assign Undocumented
Method visit_break Break node visitor.
Method visit_call Visit a Call node.
Method visit_classdef Check module name, docstring and redefinition increment branch counter.
Method visit_comprehension Undocumented
Method visit_continue Check is the node has a right sibling (if so, that's some unreachable code).
Method visit_dict Check duplicate key in dictionary.
Method visit_expr Check for various kind of statements without effect.
Method visit_for Undocumented
Method visit_functiondef Check function name, docstring, arguments, redefinition, variable names, max locals.
Method visit_if Undocumented
Method visit_ifexp Undocumented
Method visit_lambda Check whether the lambda is suspicious.
Method visit_module Check module name, docstring and required arguments.
Method visit_raise Check if the node has a right sibling (if so, that's some unreachable code).
Method visit_return Return node visitor.
Method visit_set Check duplicate value in set.
Method visit_tryfinally Update try...finally flag.
Method visit_with Undocumented
Class Variable msgs Undocumented
Class Variable name Name of the provider.
Class Variable reports Undocumented
Static Method _filter_vararg Undocumented
Static Method _has_variadic_argument Undocumented
Static Method _name_holds_generator Return whether `test` tests a name certain to hold a generator, or optionally a call that should be then tested to see if *it* returns only generators.
Method _check_dangerous_default Check for dangerous default values as arguments.
Method _check_misplaced_format_function Undocumented
Method _check_not_in_finally Check that a node is not inside a 'finally' clause of a 'try...finally' statement.
Method _check_redeclared_assign_name Undocumented
Method _check_reversed Check that the argument to `reversed` is a sequence.
Method _check_self_assigning_variable Undocumented
Method _check_unreachable Check unreachable code.
Method _check_using_constant_test Undocumented
Instance Variable _py38_plus Undocumented
Instance Variable _tryfinallys Undocumented

Inherited from BaseChecker (via _BasicChecker):

Method __eq__ Permit to assert Checkers are equal.
Method __gt__ Sorting of checkers.
Method __hash__ Make Checker hashable.
Method __repr__ Undocumented
Method __str__ This might be incomplete because multiple classes inheriting BaseChecker can have the same name.
Method add_message Undocumented
Method check_consistency Check the consistency of msgid.
Method close Called after visiting project (i.e set of modules).
Method create_message_definition_from_tuple Undocumented
Method get_full_documentation Undocumented
Method get_map_data Undocumented
Method get_message_definition Undocumented
Method reduce_map_data Undocumented
Class Variable enabled Undocumented
Class Variable options Options provided by this provider.
Instance Variable linter Undocumented
Property messages Undocumented

Inherited from _ArgumentsProvider (via _BasicChecker, BaseChecker):

Method get_option_def DEPRECATED: Return the dictionary defining an option given its name.
Method level.setter Undocumented
Method load_defaults DEPRECATED: Initialize the provider using default values.
Method option_attrname DEPRECATED: Get the config attribute corresponding to opt.
Method option_value DEPRECATED: Get the current value for the given option.
Method options_and_values DEPRECATED.
Method options_by_section DEPRECATED: Return an iterator on options grouped by section.
Method set_option DEPRECATED: Method called to set an option (registered in the options list).
Class Variable option_groups_descs Option groups of this provider and their descriptions.
Property config Undocumented
Property level Undocumented
Instance Variable _arguments_manager The manager that will parse and register any options provided.
Instance Variable _level Undocumented
def __init__(self, linter: PyLinter): (source)

Checker instances should have the linter as argument.

def leave_tryfinally(self, _: nodes.TryFinally): (source)

Update try...finally flag.

def open(self): (source)

Initialize visit variables and statistics.

@utils.only_required_for_messages('assert-on-tuple', 'assert-on-string-literal')
def visit_assert(self, node: nodes.Assert): (source)

Check whether assert is used on a tuple or string literal.

@utils.only_required_for_messages('self-assigning-variable', 'redeclared-assigned-name')
def visit_assign(self, node: nodes.Assign): (source)

Undocumented

@utils.only_required_for_messages('unreachable', 'lost-exception')
def visit_break(self, node: nodes.Break): (source)

Break node visitor. 1 - check if the node has a right sibling (if so, that's some unreachable code) 2 - check if the node is inside the 'finally' clause of a 'try...finally' block

@utils.only_required_for_messages('eval-used', 'exec-used', 'bad-reversed-sequence', 'misplaced-format-function', 'unreachable')
def visit_call(self, node: nodes.Call): (source)

Visit a Call node.

def visit_classdef(self, _: nodes.ClassDef): (source)

Check module name, docstring and redefinition increment branch counter.

@utils.only_required_for_messages('using-constant-test', 'missing-parentheses-for-call-in-test')
def visit_comprehension(self, node: nodes.Comprehension): (source)

Undocumented

@utils.only_required_for_messages('unreachable')
def visit_continue(self, node: nodes.Continue): (source)

Check is the node has a right sibling (if so, that's some unreachable code).

@utils.only_required_for_messages('duplicate-key')
def visit_dict(self, node: nodes.Dict): (source)

Check duplicate key in dictionary.

@utils.only_required_for_messages('pointless-statement', 'pointless-exception-statement', 'pointless-string-statement', 'expression-not-assigned', 'named-expr-without-context')
def visit_expr(self, node: nodes.Expr): (source)

Check for various kind of statements without effect.

@utils.only_required_for_messages('redeclared-assigned-name')
def visit_for(self, node: nodes.For): (source)

Undocumented

@utils.only_required_for_messages('dangerous-default-value')
def visit_functiondef(self, node: nodes.FunctionDef): (source)

Check function name, docstring, arguments, redefinition, variable names, max locals.

@utils.only_required_for_messages('using-constant-test', 'missing-parentheses-for-call-in-test')
def visit_if(self, node: nodes.If): (source)

Undocumented

@utils.only_required_for_messages('using-constant-test', 'missing-parentheses-for-call-in-test')
def visit_ifexp(self, node: nodes.IfExp): (source)

Undocumented

@utils.only_required_for_messages('unnecessary-lambda')
def visit_lambda(self, node: nodes.Lambda): (source)

Check whether the lambda is suspicious.

def visit_module(self, _: nodes.Module): (source)

Check module name, docstring and required arguments.

@utils.only_required_for_messages('unreachable')
def visit_raise(self, node: nodes.Raise): (source)

Check if the node has a right sibling (if so, that's some unreachable code).

@utils.only_required_for_messages('unreachable', 'lost-exception')
def visit_return(self, node: nodes.Return): (source)

Return node visitor. 1 - check if the node has a right sibling (if so, that's some unreachable code) 2 - check if the node is inside the 'finally' clause of a 'try...finally' block

@utils.only_required_for_messages('duplicate-value')
def visit_set(self, node: nodes.Set): (source)

Check duplicate value in set.

def visit_tryfinally(self, node: nodes.TryFinally): (source)

Update try...finally flag.

@utils.only_required_for_messages('confusing-with-statement')
def visit_with(self, node: nodes.With): (source)

Undocumented

@staticmethod
def _filter_vararg(node: nodes.Lambda, call_args: list[nodes.NodeNG]) -> Iterator[nodes.NodeNG]: (source)

Undocumented

@staticmethod
def _has_variadic_argument(args: list[nodes.Starred|nodes.Keyword], variadic_name: str) -> bool: (source)

Undocumented

@staticmethod
def _name_holds_generator(test: nodes.Name) -> tuple[bool, nodes.Call|None]: (source)

Return whether `test` tests a name certain to hold a generator, or optionally a call that should be then tested to see if *it* returns only generators.

def _check_dangerous_default(self, node: nodes.FunctionDef): (source)

Check for dangerous default values as arguments.

def _check_misplaced_format_function(self, call_node: nodes.Call): (source)

Undocumented

def _check_not_in_finally(self, node: nodes.Break|nodes.Return, node_name: str, breaker_classes: tuple[nodes.NodeNG, ...] = ()): (source)

Check that a node is not inside a 'finally' clause of a 'try...finally' statement. If we find a parent which type is in breaker_classes before a 'try...finally' block we skip the whole check.

def _check_redeclared_assign_name(self, targets: list[nodes.NodeNG|None]): (source)

Undocumented

def _check_reversed(self, node: nodes.Call): (source)

Check that the argument to `reversed` is a sequence.

def _check_self_assigning_variable(self, node: nodes.Assign): (source)

Undocumented

def _check_unreachable(self, node: (((nodes.Return|nodes.Continue)|nodes.Break)|nodes.Raise)|nodes.Call, confidence: Confidence = HIGH): (source)

Check unreachable code.

def _check_using_constant_test(self, node: (nodes.If|nodes.IfExp)|nodes.Comprehension, test: nodes.NodeNG|None): (source)

Undocumented

_py38_plus = (source)

Undocumented

_tryfinallys: list = (source)

Undocumented