class documentation

class CodeStyleChecker(BaseChecker): (source)

View In Hierarchy

Checkers that can improve code consistency. As such they don't necessarily provide a performance benefit and are often times opinionated. Before adding another checker here, consider this: 1. Does the checker provide a clear benefit, i.e. detect a common issue or improve performance => it should probably be part of the core checker classes 2. Is it something that would improve code consistency, maybe because it's slightly better with regard to performance and therefore preferred => this is the right place 3. Everything else should go into another extension

Method open Called before visiting project (i.e. set of modules).
Method visit_assign Undocumented
Method visit_comprehension Undocumented
Method visit_dict Undocumented
Method visit_for Undocumented
Method visit_if Undocumented
Class Variable msgs Undocumented
Class Variable name Name of the provider.
Class Variable options Options provided by this provider.
Static Method _check_ignore_assignment_expr_suggestion Return True if suggestion for assignment expr should be ignored.
Static Method _check_prev_sibling_to_if_stmt Check if previous sibling is an assignment with the same name.
Method _check_consider_using_assignment_expr Check if an assignment expression (walrus operator) can be used.
Method _check_dict_consider_namedtuple_dataclass Check if dictionary values can be replaced by Namedtuple or Dataclass.
Instance Variable _max_length Undocumented
Instance Variable _py38_plus Undocumented

Inherited from BaseChecker:

Method __eq__ Permit to assert Checkers are equal.
Method __gt__ Sorting of checkers.
Method __hash__ Make Checker hashable.
Method __init__ Checker instances should have the linter as argument.
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 reports Undocumented
Instance Variable linter Undocumented
Property messages Undocumented

Inherited from _ArgumentsProvider (via 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 open(self): (source)

Called before visiting project (i.e. set of modules).

@only_required_for_messages('consider-using-augmented-assign')
def visit_assign(self, node: nodes.Assign): (source)

Undocumented

@only_required_for_messages('consider-using-tuple')
def visit_comprehension(self, node: nodes.Comprehension): (source)

Undocumented

@only_required_for_messages('consider-using-namedtuple-or-dataclass')
def visit_dict(self, node: nodes.Dict): (source)

Undocumented

@only_required_for_messages('consider-using-tuple')
def visit_for(self, node: nodes.For): (source)

Undocumented

@only_required_for_messages('consider-using-assignment-expr')
def visit_if(self, node: nodes.If): (source)

Undocumented

Name of the provider.

options: tuple[tuple, ...] = (source)

Options provided by this provider.

@staticmethod
def _check_ignore_assignment_expr_suggestion(node: nodes.If, name: str|None) -> bool: (source)

Return True if suggestion for assignment expr should be ignored. E.g., in cases where a match statement would be a better fit (multiple conditions).

@staticmethod
def _check_prev_sibling_to_if_stmt(prev_sibling: nodes.NodeNG|None, name: str|None) -> TypeGuard[nodes.Assign|nodes.AnnAssign]: (source)

Check if previous sibling is an assignment with the same name. Ignore statements which span multiple lines.

def _check_consider_using_assignment_expr(self, node: nodes.If): (source)

Check if an assignment expression (walrus operator) can be used. For example if an assignment is directly followed by an if statement: >>> x = 2 >>> if x: >>> ... Can be replaced by: >>> if (x := 2): >>> ... Note: Assignment expressions were added in Python 3.8

def _check_dict_consider_namedtuple_dataclass(self, node: nodes.Dict): (source)

Check if dictionary values can be replaced by Namedtuple or Dataclass.

_max_length: int = (source)

Undocumented

_py38_plus = (source)

Undocumented