diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aeff2dc6e3a..92645ccef15 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,18 +36,6 @@ repos: - id: black args: [--safe, --quiet] exclude: *fixtures - - repo: https://github.com/Pierre-Sassoulas/docformatter - rev: master - hooks: - - id: docformatter - # black want 88 char per line max, +3 quotes for docstring summaries - args: - [ - "--in-place", - "--wrap-summaries=88", - "--wrap-descriptions=88", - ] - exclude: *fixtures - repo: https://github.com/Pierre-Sassoulas/black-disable-checker/ rev: 1.0.1 hooks: diff --git a/examples/custom_raw.py b/examples/custom_raw.py index e32809ffcb9..95286fc5e8b 100644 --- a/examples/custom_raw.py +++ b/examples/custom_raw.py @@ -11,7 +11,8 @@ class MyRawChecker(BaseChecker): """Check for line continuations with '\' instead of using triple quoted string or - parenthesis.""" + parenthesis. + """ __implements__ = IRawChecker diff --git a/pylint/checkers/__init__.py b/pylint/checkers/__init__.py index 56404256949..542ce017173 100644 --- a/pylint/checkers/__init__.py +++ b/pylint/checkers/__init__.py @@ -66,7 +66,8 @@ def table_lines_from_stats( stat_type: Literal["duplicated_lines", "message_types"], ) -> List[str]: """Get values listed in from and , and return a - formatted list of values, designed to be given to a ureport.Table object.""" + formatted list of values, designed to be given to a ureport.Table object. + """ lines: List[str] = [] if stat_type == "duplicated_lines": new: List[Tuple[str, Union[str, int, float]]] = [ diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 426592d5abd..48f26901e3f 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -103,7 +103,8 @@ class NamingStyle: """It may seem counterintuitive that single naming style has multiple "accepted" forms of regular expressions, but we need to special-case stuff like dunder names in - method names.""" + method names. + """ ANY: Pattern[str] = re.compile(".*") CLASS_NAME_RGX: Pattern[str] = ANY @@ -1300,7 +1301,8 @@ def visit_lambda(self, node: nodes.Lambda) -> None: @utils.check_messages("dangerous-default-value") def visit_functiondef(self, node: nodes.FunctionDef) -> None: """Check function name, docstring, args, redefinition, variable names, - locals.""" + locals. + """ if node.is_method(): self.linter.stats.node_count["method"] += 1 else: @@ -1363,7 +1365,8 @@ def visit_return(self, node: nodes.Return) -> None: @utils.check_messages("unreachable") def visit_continue(self, node: nodes.Continue) -> None: """Check is the node has a right sibling (if so, that's some unreachable - code)""" + code) + """ self._check_unreachable(node) @utils.check_messages("unreachable", "lost-exception") @@ -1381,7 +1384,8 @@ def visit_break(self, node: nodes.Break) -> None: @utils.check_messages("unreachable") def visit_raise(self, node: nodes.Raise) -> None: """Check if the node has a right sibling (if so, that's some unreachable - code)""" + code) + """ self._check_unreachable(node) def _check_misplaced_format_function(self, call_node): diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py index 55634c3f0d0..ff87b06fb5d 100644 --- a/pylint/checkers/classes/class_checker.py +++ b/pylint/checkers/classes/class_checker.py @@ -840,7 +840,8 @@ def _check_proper_bases(self, node): def _check_typing_final(self, node: nodes.ClassDef) -> None: """Detect that a class does not subclass a class decorated with - `typing.final`""" + `typing.final` + """ if not self._py38_plus: return for base in node.bases: @@ -1872,7 +1873,8 @@ def is_abstract(method): def _check_init(self, node): """Check that the __init__ method call super or ancestors'__init__ method - (unless it is used for type hinting with `typing.overload`)""" + (unless it is used for type hinting with `typing.overload`) + """ if not self.linter.is_message_enabled( "super-init-not-called" ) and not self.linter.is_message_enabled("non-parent-init-called"): @@ -2027,7 +2029,8 @@ def _is_mandatory_method_param(self, node): def _ancestors_to_call(klass_node, method="__init__"): """Return a dictionary where keys are the list of base classes providing the queried - method, and so that should/may be called from the method node.""" + method, and so that should/may be called from the method node. + """ to_call = {} for base_node in klass_node.ancestors(recurs=False): try: diff --git a/pylint/checkers/design_analysis.py b/pylint/checkers/design_analysis.py index fc11154bfba..4be86453ac3 100644 --- a/pylint/checkers/design_analysis.py +++ b/pylint/checkers/design_analysis.py @@ -528,7 +528,8 @@ def leave_classdef(self, node: nodes.ClassDef) -> None: ) def visit_functiondef(self, node: nodes.FunctionDef) -> None: """Check function name, docstring, arguments, redefinition, variable names, max - locals.""" + locals. + """ # init branch and returns counters self._returns.append(0) # check number of arguments @@ -637,7 +638,8 @@ def visit_if(self, node: nodes.If) -> None: def _check_boolean_expressions(self, node): """Go through "if" node `node` and count its boolean expressions if the 'if' - node test is a BoolOp node.""" + node test is a BoolOp node. + """ condition = node.test if not isinstance(condition, astroid.BoolOp): return diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py index 98fdb6f9bf3..8042310b857 100644 --- a/pylint/checkers/format.py +++ b/pylint/checkers/format.py @@ -716,7 +716,8 @@ def is_line_length_check_activated(pylint_pattern_match_object) -> bool: @staticmethod def specific_splitlines(lines: str) -> List[str]: """Split lines according to universal newlines except those in a specific - sets.""" + sets. + """ unsplit_ends = { "\v", "\x0b", diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index fae217d5991..2e78199851f 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -139,7 +139,8 @@ def _ignore_import_failure(node, modname, ignored_modules): def _make_tree_defs(mod_files_list): """Get a list of 2-uple (module, list_of_files_which_import_this_module), it will - return a dictionary to represent this as a tree.""" + return a dictionary to represent this as a tree. + """ tree_defs = {} for mod, files in mod_files_list: node = (tree_defs, ()) @@ -192,7 +193,8 @@ def _make_graph( filename: str, dep_info: Dict[str, Set[str]], sect: Section, gtype: str ): """Generate a dependencies graph and add some information about it in the report's - section.""" + section. + """ outputfile = _dependencies_graph(filename, dep_info) sect.append(Paragraph((f"{gtype}imports graph has been written to {outputfile}",))) diff --git a/pylint/checkers/refactoring/implicit_booleaness_checker.py b/pylint/checkers/refactoring/implicit_booleaness_checker.py index cd204a47db5..fbe56d35235 100644 --- a/pylint/checkers/refactoring/implicit_booleaness_checker.py +++ b/pylint/checkers/refactoring/implicit_booleaness_checker.py @@ -128,7 +128,8 @@ def instance_has_bool(class_def: nodes.ClassDef) -> bool: @utils.check_messages("use-implicit-booleaness-not-len") def visit_unaryop(self, node: nodes.UnaryOp) -> None: """`not len(S)` must become `not S` regardless if the parent block is a test - condition or something else (boolean expression) e.g. `if not len(S):`""" + condition or something else (boolean expression) e.g. `if not len(S):` + """ if ( isinstance(node, nodes.UnaryOp) and node.op == "not" @@ -209,7 +210,8 @@ def _check_use_implicit_booleaness_not_comparison( @staticmethod def base_classes_of_node(instance: nodes.ClassDef) -> List[str]: """Return all the classes names that a ClassDef inherit from including - 'object'.""" + 'object'. + """ try: return [instance.name] + [x.name for x in instance.ancestors()] except TypeError: diff --git a/pylint/checkers/refactoring/recommendation_checker.py b/pylint/checkers/refactoring/recommendation_checker.py index 405e094ea04..c2fbe333287 100644 --- a/pylint/checkers/refactoring/recommendation_checker.py +++ b/pylint/checkers/refactoring/recommendation_checker.py @@ -103,7 +103,8 @@ def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None: def _check_use_maxsplit_arg(self, node: nodes.Call) -> None: """Add message when accessing first or last elements of a str.split() or - str.rsplit().""" + str.rsplit(). + """ # Check if call is split() or rsplit() if not ( @@ -338,7 +339,8 @@ def visit_const(self, node: nodes.Const) -> None: def _detect_replacable_format_call(self, node: nodes.Const) -> None: """Check whether a string is used in a call to format() or '%' and whether it - can be replaced by an f-string.""" + can be replaced by an f-string. + """ if ( isinstance(node.parent, nodes.Attribute) and node.parent.attrname == "format" diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py index 26e06a8742f..e4bbf83be41 100644 --- a/pylint/checkers/refactoring/refactoring_checker.py +++ b/pylint/checkers/refactoring/refactoring_checker.py @@ -119,7 +119,8 @@ def _is_a_return_statement(node: nodes.Call) -> bool: def _is_part_of_with_items(node: nodes.Call) -> bool: """Checks if one of the node's parents is a ``nodes.With`` node and that the node - itself is located somewhere under its ``items``.""" + itself is located somewhere under its ``items``. + """ frame = node.frame() current = node while current != frame: @@ -133,7 +134,8 @@ def _is_part_of_with_items(node: nodes.Call) -> bool: def _will_be_released_automatically(node: nodes.Call) -> bool: """Checks if a call that could be used in a ``with`` statement is used in an - alternative construct which would ensure that its __exit__ method is called.""" + alternative construct which would ensure that its __exit__ method is called. + """ callables_taking_care_of_exit = frozenset( ( "contextlib._BaseExitStack.enter_context", @@ -150,7 +152,8 @@ def _will_be_released_automatically(node: nodes.Call) -> bool: class ConsiderUsingWithStack(NamedTuple): """Stack for objects that may potentially trigger a R1732 message if they are not - used in a ``with`` block later on.""" + used in a ``with`` block later on. + """ module_scope: Dict[str, nodes.NodeNG] = {} class_scope: Dict[str, nodes.NodeNG] = {} diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index f5094bfccd9..90cfec2a962 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -113,7 +113,8 @@ class LineSpecifs(NamedTuple): class CplSuccessiveLinesLimits: """This class holds a couple of SuccessiveLinesLimits objects, one for each file compared, and a counter on the number of common lines between both stripped lines - collections extracted from both files.""" + collections extracted from both files. + """ __slots__ = ("first_file", "second_file", "effective_cmn_lines_nb") @@ -135,7 +136,8 @@ def __init__( class LinesChunk: """The LinesChunk object computes and stores the hash of some consecutive stripped - lines of a lineset.""" + lines of a lineset. + """ __slots__ = ("_fileid", "_index", "_hash") @@ -597,7 +599,8 @@ def _get_functions( functions: List[nodes.NodeNG], tree: nodes.NodeNG ) -> List[nodes.NodeNG]: """Recursively get all functions including nested in the classes from the - tree.""" + tree. + """ for node in tree.body: if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)): diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py index a7e5ef2a307..343f2d1a661 100644 --- a/pylint/checkers/spelling.py +++ b/pylint/checkers/spelling.py @@ -146,7 +146,8 @@ class SphinxDirectives(RegExFilter): class ForwardSlashChunker(Chunker): """This chunker allows splitting words like 'before/after' into 'before' and - 'after'.""" + 'after'. + """ def next(self): while True: diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py index e32f6655b21..603ed6879e1 100644 --- a/pylint/checkers/strings.py +++ b/pylint/checkers/strings.py @@ -227,7 +227,8 @@ def get_access_path(key, parts): """Given a list of format specifiers, returns the final access path (e.g. - a.b.c[0][1]).""" + a.b.c[0][1]). + """ path = [] for is_attribute, specifier in parts: if is_attribute: @@ -256,7 +257,8 @@ def arg_matches_format_type(arg_type, format_type): class StringFormatChecker(BaseChecker): """Checks string formatting operations to ensure that the format string is valid and - the arguments match the format string.""" + the arguments match the format string. + """ __implements__ = (IAstroidChecker,) name = "string" @@ -538,7 +540,8 @@ def _check_new_format(self, node, func): def _check_new_format_specifiers(self, node, fields, named): """Check attribute and index access in the format string ("{0.a}" and - "{0[a]}").""" + "{0[a]}"). + """ for key, specifiers in fields: # Obtain the argument. If it can't be obtained # or inferred, skip this check. diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 6fd1361b7f6..565dd6d4ac4 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -1141,7 +1141,8 @@ def visit_assign(self, node: nodes.Assign) -> None: def _check_assignment_from_function_call(self, node): """Check that if assigning to a function call, the function is possibly - returning something valuable.""" + returning something valuable. + """ if not isinstance(node.value, nodes.Call): return @@ -1209,7 +1210,8 @@ def _check_dundername_is_string(self, node): def _check_uninferable_call(self, node): """Check that the given uninferable Call node does not call an actual - function.""" + function. + """ if not isinstance(node.func, nodes.Attribute): return @@ -1310,7 +1312,8 @@ def _check_isinstance_args(self, node): def visit_call(self, node: nodes.Call) -> None: """Check that called functions/methods are inferred to callable objects, and that the arguments passed to the function match the parameters in the inferred - function's definition.""" + function's definition. + """ called = safe_infer(node.func) self._check_not_callable(node, called) @@ -1508,7 +1511,8 @@ def _keyword_argument_is_in_all_decorator_returns( func: nodes.FunctionDef, keyword: str ) -> bool: """Check if the keyword argument exists in all signatures of the return values - of all decorators of the function.""" + of all decorators of the function. + """ if not func.decorators: return False diff --git a/pylint/checkers/unsupported_version.py b/pylint/checkers/unsupported_version.py index b56b5738f09..3f759a6c760 100644 --- a/pylint/checkers/unsupported_version.py +++ b/pylint/checkers/unsupported_version.py @@ -28,7 +28,8 @@ class UnsupportedVersionChecker(BaseChecker): """Checker for features that are not supported by all python versions indicated by - the py-version setting.""" + the py-version setting. + """ __implements__ = (IAstroidChecker,) name = "unsupported_version" @@ -66,7 +67,8 @@ def visit_decorators(self, node: nodes.Decorators) -> None: def _check_typing_final(self, node: nodes.Decorators) -> None: """Add a message when the `typing.final` decorator is used and the py- version - is lower than 3.8.""" + is lower than 3.8. + """ if self._py38_plus: return diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index ba9b20f1c24..188e362a465 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -417,7 +417,8 @@ def is_default_argument( node: nodes.NodeNG, scope: Optional[nodes.NodeNG] = None ) -> bool: """return true if the given Name node is used in function or lambda default - argument's value.""" + argument's value. + """ if not scope: scope = node.scope() if isinstance(scope, (nodes.FunctionDef, nodes.Lambda)): @@ -452,7 +453,8 @@ def is_func_decorator(node: nodes.NodeNG) -> bool: def is_ancestor_name(frame: nodes.ClassDef, node: nodes.NodeNG) -> bool: """return whether `frame` is an astroid.Class node with `node` in the subtree of its - bases attribute.""" + bases attribute. + """ if not isinstance(frame, nodes.ClassDef): return False return any(node in base.nodes_of_class(nodes.Name) for base in frame.bases) @@ -472,7 +474,8 @@ def assign_parent(node: nodes.NodeNG) -> nodes.NodeNG: def overrides_a_method(class_node: nodes.ClassDef, name: str) -> bool: """return True if is a method overridden from an ancestor which is not the - base object class.""" + base object class. + """ for ancestor in class_node.ancestors(): if ancestor.name == "object": continue @@ -497,7 +500,8 @@ class IncompleteFormatString(Exception): class UnsupportedFormatCharacter(Exception): """A format character in a format string is not one of the supported format - characters.""" + characters. + """ def __init__(self, index): super().__init__(index) @@ -628,7 +632,8 @@ def parse_format_method_string( implicit_pos_args_cnt, explicit_pos_args), where keyword_arguments is the set of mapping keys in the format string, implicit_pos_args_cnt is the number of arguments required by the format string and explicit_pos_args is the number of arguments - passed with the position.""" + passed with the position. + """ keyword_arguments = [] implicit_pos_args_cnt = 0 explicit_pos_args = set() @@ -650,7 +655,8 @@ def parse_format_method_string( def is_attr_protected(attrname: str) -> bool: """return True if attribute name is protected (start with _ and some other details), - False otherwise.""" + False otherwise. + """ return ( attrname[0] == "_" and attrname != "_" @@ -692,7 +698,8 @@ def get_outer_class(class_node: astroid.ClassDef) -> Optional[astroid.ClassDef]: def is_attr_private(attrname: str) -> Optional[Match[str]]: """Check that attribute name is private (at least two leading underscores, at most - one trailing underscore)""" + one trailing underscore) + """ regex = re.compile("^_{2,}.*[^_]+_?$") return regex.match(attrname) @@ -1651,7 +1658,8 @@ def is_node_in_guarded_import_block(node: nodes.NodeNG) -> bool: def is_reassigned_after_current(node: nodes.NodeNG, varname: str) -> bool: """Check if the given variable name is reassigned in the same scope after the - current node.""" + current node. + """ return any( a.name == varname and a.lineno > node.lineno for a in node.scope().nodes_of_class((nodes.AssignName, nodes.FunctionDef)) diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index b5b2b7866f4..1146f119969 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -204,7 +204,8 @@ def overridden_method(klass, name): def _get_unpacking_extra_info(node, inferred): """return extra information to add to the message for unpacking-non- sequence and - unbalanced-tuple-unpacking errors.""" + unbalanced-tuple-unpacking errors. + """ more = "" inferred_module = inferred.root().name if node.root().name == inferred_module: @@ -541,7 +542,8 @@ def _has_locals_call_after_node(stmt, scope): class NamesConsumer: """A simple class to handle consumed, to consume and scope type info of node - locals.""" + locals. + """ def __init__(self, node, scope_type): self._atomic = ScopeConsumer( @@ -696,7 +698,8 @@ def get_next_to_consume(self, node): @staticmethod def _uncertain_nodes_in_except_blocks(found_nodes, node, node_statement): """Return any nodes in ``found_nodes`` that should be treated as uncertain - because they are in an except block.""" + because they are in an except block. + """ uncertain_nodes = [] for other_node in found_nodes: other_node_statement = other_node.statement(future=True) @@ -1193,7 +1196,8 @@ def _should_node_be_skipped( self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool ) -> bool: """Tests a consumer and node for various conditions in which the node shouldn't - be checked for the undefined-variable and used-before- assignment checks.""" + be checked for the undefined-variable and used-before- assignment checks. + """ if consumer.scope_type == "class": # The list of base classes in the class definition is not part # of the class body. @@ -1468,7 +1472,8 @@ def visit_importfrom(self, node: nodes.ImportFrom) -> None: ) def visit_assign(self, node: nodes.Assign) -> None: """Check unbalanced tuple unpacking for assignments and unpacking non- sequences - as well as in case self/cls get assigned.""" + as well as in case self/cls get assigned. + """ self._check_self_cls_assign(node) if not isinstance(node.targets[0], (nodes.Tuple, nodes.List)): return @@ -1543,7 +1548,8 @@ def _in_lambda_or_comprehension_body( node: nodes.NodeNG, frame: nodes.NodeNG ) -> bool: """return True if node within a lambda/comprehension body (or similar) and thus - should not have access to class attributes in frame.""" + should not have access to class attributes in frame. + """ child = node parent = node.parent while parent is not None: @@ -2282,7 +2288,8 @@ def _check_unpacking(self, inferred, node, targets): def _check_module_attrs(self, node, module, module_names): """Check that module_names (list of string) are accessible through the given - module if the latest access name corresponds to a module, return it.""" + module if the latest access name corresponds to a module, return it. + """ while module_names: name = module_names.pop(0) if name == "__dict__": diff --git a/pylint/config/config_initialization.py b/pylint/config/config_initialization.py index 79b59b34dc4..a006901a8ef 100644 --- a/pylint/config/config_initialization.py +++ b/pylint/config/config_initialization.py @@ -20,7 +20,8 @@ def _config_initialization( verbose_mode: Optional[bool] = None, ) -> List[str]: """Parse all available options, read config files and command line arguments and set - options accordingly.""" + options accordingly. + """ # Read the config file. The parser is stored on linter.cfgfile_parser try: diff --git a/pylint/config/configuration_mixin.py b/pylint/config/configuration_mixin.py index 704cc0a3da5..c5f29781d9f 100644 --- a/pylint/config/configuration_mixin.py +++ b/pylint/config/configuration_mixin.py @@ -7,7 +7,8 @@ class ConfigurationMixIn(OptionsManagerMixIn, OptionsProviderMixIn): """Basic mixin for simple configurations which don't need the manager / providers - model.""" + model. + """ def __init__(self, *args, **kwargs): if not args: diff --git a/pylint/config/find_default_config_files.py b/pylint/config/find_default_config_files.py index 60074a8f260..8d1fc1885dc 100644 --- a/pylint/config/find_default_config_files.py +++ b/pylint/config/find_default_config_files.py @@ -72,7 +72,8 @@ def find_default_config_files() -> Iterator[str]: def find_pylintrc() -> Optional[str]: """Search the pylint rc file and return its path if it finds it, else return - None.""" + None. + """ for config_file in find_default_config_files(): if config_file.endswith("pylintrc"): return config_file diff --git a/pylint/config/option_manager_mixin.py b/pylint/config/option_manager_mixin.py index 9fcc649204f..930ba4812f6 100644 --- a/pylint/config/option_manager_mixin.py +++ b/pylint/config/option_manager_mixin.py @@ -142,7 +142,8 @@ def add_optik_option(self, provider, optikcontainer, opt, optdict): def optik_option(self, provider, opt, optdict): """get our personal option definition and return a suitable form for use with - optik/optparse.""" + optik/optparse. + """ optdict = copy.copy(optdict) if "action" in optdict: self._nocallback_options[provider] = opt @@ -191,7 +192,8 @@ def generate_config( self, stream: Optional[TextIO] = None, skipsections: Tuple[str, ...] = () ) -> None: """write a configuration file according to the current configuration into the - given stream or stdout.""" + given stream or stdout. + """ options_by_section: Dict[str, List[Tuple]] = {} sections = [] for provider in self.options_providers: @@ -242,7 +244,8 @@ def load_provider_defaults(self): def read_config_file(self, config_file=None, verbose=None): """Read the configuration file but do not load it (i.e. dispatching values to - each option's provider)""" + each option's provider) + """ for help_level in range(1, self._maxlevel + 1): opt = "-".join(["long"] * help_level) + "-help" if opt in self._all_options: @@ -328,7 +331,8 @@ def _parse_toml( def load_config_file(self): """Dispatch values previously read from a configuration file to each option's - provider.""" + provider. + """ parser = self.cfgfile_parser for section in parser.sections(): for option, value in parser.items(section): diff --git a/pylint/exceptions.py b/pylint/exceptions.py index 7ea5f9c57d0..56e56b36577 100644 --- a/pylint/exceptions.py +++ b/pylint/exceptions.py @@ -37,4 +37,5 @@ class InvalidArgsError(ValueError): class NoLineSuppliedError(Exception): """raised when trying to disable a message on a next line without supplying a line - number.""" + number. + """ diff --git a/pylint/extensions/confusing_elif.py b/pylint/extensions/confusing_elif.py index ad2eea97125..f490a54f192 100644 --- a/pylint/extensions/confusing_elif.py +++ b/pylint/extensions/confusing_elif.py @@ -21,7 +21,8 @@ class ConfusingConsecutiveElifChecker(BaseChecker): """Checks if "elif" is used right after an indented block that finishes with "if" or - "elif" itself.""" + "elif" itself. + """ __implements__ = IAstroidChecker diff --git a/pylint/extensions/for_any_all.py b/pylint/extensions/for_any_all.py index 9a7fc254c1b..690fc7bbf9d 100644 --- a/pylint/extensions/for_any_all.py +++ b/pylint/extensions/for_any_all.py @@ -49,7 +49,8 @@ def visit_for(self, node: nodes.For) -> None: def _build_suggested_string(node: nodes.For, final_return_bool: bool) -> str: """When a nodes.For node can be rewritten as an any/all statement, return a suggestion for that statement final_return_bool is the boolean literal returned - after the for loop if all conditions fail.""" + after the for loop if all conditions fail. + """ loop_var = node.target.as_string() loop_iter = node.iter.as_string() test_node = next(node.body[0].get_children()) diff --git a/pylint/extensions/mccabe.py b/pylint/extensions/mccabe.py index 6f284a52b02..1b83f9840d5 100644 --- a/pylint/extensions/mccabe.py +++ b/pylint/extensions/mccabe.py @@ -152,7 +152,8 @@ def _subgraph_parse(self, node, pathnode, extra_blocks): class McCabeMethodChecker(checkers.BaseChecker): """Checks McCabe complexity cyclomatic threshold in methods and functions to - validate a too complex code.""" + validate a too complex code. + """ __implements__ = IAstroidChecker name = "design" @@ -180,7 +181,8 @@ class McCabeMethodChecker(checkers.BaseChecker): @check_messages("too-complex") def visit_module(self, node: nodes.Module) -> None: """visit an astroid.Module node to check too complex rating and add message if - is greater than max_complexity stored from options.""" + is greater than max_complexity stored from options. + """ visitor = PathGraphingAstVisitor() for child in node.body: visitor.preorder(child, visitor) diff --git a/pylint/extensions/overlapping_exceptions.py b/pylint/extensions/overlapping_exceptions.py index ab939be4d79..c849388f5db 100644 --- a/pylint/extensions/overlapping_exceptions.py +++ b/pylint/extensions/overlapping_exceptions.py @@ -18,7 +18,8 @@ class OverlappingExceptionsChecker(checkers.BaseChecker): """Checks for two or more exceptions in the same exception handler clause that are - identical or parts of the same inheritance hierarchy (i.e. overlapping).""" + identical or parts of the same inheritance hierarchy (i.e. overlapping). + """ __implements__ = interfaces.IAstroidChecker diff --git a/pylint/graph.py b/pylint/graph.py index c8845fcc4d1..cdaa05e332b 100644 --- a/pylint/graph.py +++ b/pylint/graph.py @@ -176,7 +176,8 @@ def normalize_node_id(nid): def get_cycles(graph_dict, vertices=None): """given a dictionary representing an ordered graph (i.e. key are vertices and values is a list of destination vertices representing edges), return a list of - detected cycles.""" + detected cycles. + """ if not graph_dict: return () result = [] diff --git a/pylint/interfaces.py b/pylint/interfaces.py index cd31f488adf..a2e03f87587 100644 --- a/pylint/interfaces.py +++ b/pylint/interfaces.py @@ -103,7 +103,8 @@ def process_tokens(self, tokens): class IAstroidChecker(IChecker): """interface for checker which prefers receive events according to statement - type.""" + type. + """ class IReporter(Interface): diff --git a/pylint/lint/expand_modules.py b/pylint/lint/expand_modules.py index ef3020a9be5..2c7a5199aef 100644 --- a/pylint/lint/expand_modules.py +++ b/pylint/lint/expand_modules.py @@ -46,7 +46,8 @@ def expand_modules( ignore_list_paths_re: List[Pattern[str]], ) -> Tuple[List[ModuleDescriptionDict], List[ErrorDescriptionDict]]: """take a list of files/modules/packages and return the list of tuple (file, module - name) which have to be actually checked.""" + name) which have to be actually checked. + """ result: List[ModuleDescriptionDict] = [] errors: List[ErrorDescriptionDict] = [] path = sys.path.copy() diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index 1a3923db8af..584995be6fd 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -626,7 +626,8 @@ def load_default_plugins(self): def load_plugin_modules(self, modnames): """take a list of module names which are pylint plugins and load and register - them.""" + them. + """ for modname in modnames: if modname in self._dynamic_plugins: continue @@ -704,7 +705,8 @@ def set_reporter( def set_option(self, optname, value, action=None, optdict=None): """overridden from config.OptionsProviderMixin to handle some special - options.""" + options. + """ if optname in self._options_methods or optname in self._bw_options_methods: if value: try: @@ -850,7 +852,8 @@ def list_messages_enabled(self): def process_tokens(self, tokens): """Process tokens from the current module to search for module/block level - options.""" + options. + """ control_pragmas = {"disable", "disable-next", "enable"} prev_line = None saw_newline = True @@ -1466,7 +1469,8 @@ def _add_one_message( end_col_offset: Optional[int], ) -> None: """After various checks have passed a single Message is passed to the reporter - and added to stats.""" + and added to stats. + """ message_definition.check_message_definition(line, node) # Look up "location" data of node if not yet supplied @@ -1624,7 +1628,8 @@ def _get_messages_to_set( self, msgid: str, enable: bool, ignore_unknown: bool = False ) -> List[MessageDefinition]: """Do some tests and find the actual messages of which the status should be - set.""" + set. + """ message_definitions = [] if msgid == "all": for _msgid in MSG_TYPES: @@ -1700,7 +1705,8 @@ def _register_by_id_managed_msg( self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = True ) -> None: """If the msgid is a numeric one, then register it to inform the user it could - furnish instead a symbolic msgid.""" + furnish instead a symbolic msgid. + """ if msgid_or_symbol[1:].isdigit(): try: symbol = self.msgs_store.message_id_store.get_symbol( diff --git a/pylint/message/message_definition_store.py b/pylint/message/message_definition_store.py index 70a9e5ef36d..aadee04856d 100644 --- a/pylint/message/message_definition_store.py +++ b/pylint/message/message_definition_store.py @@ -16,7 +16,8 @@ class MessageDefinitionStore: """The messages store knows information about every possible message definition but - has no particular state during analysis.""" + has no particular state during analysis. + """ def __init__(self) -> None: self.message_id_store: MessageIdStore = MessageIdStore() diff --git a/pylint/message/message_id_store.py b/pylint/message/message_id_store.py index 91c5eb3c211..d975f1bb7a6 100644 --- a/pylint/message/message_id_store.py +++ b/pylint/message/message_id_store.py @@ -9,7 +9,8 @@ class MessageIdStore: """The MessageIdStore store MessageId and make sure that there is a 1-1 relation - between msgid and symbol.""" + between msgid and symbol. + """ def __init__(self) -> None: self.__msgid_to_symbol: Dict[str, str] = {} diff --git a/pylint/pyreverse/diadefslib.py b/pylint/pyreverse/diadefslib.py index 494de516764..5baf59bb537 100644 --- a/pylint/pyreverse/diadefslib.py +++ b/pylint/pyreverse/diadefslib.py @@ -184,11 +184,13 @@ def visit_importfrom(self, node: nodes.ImportFrom) -> None: class ClassDiadefGenerator(DiaDefGenerator): """generate a class diagram definition including all classes related to a given - class.""" + class. + """ def class_diagram(self, project, klass): """return a class diagram definition for the given klass and its related - klasses.""" + klasses. + """ self.classdiagram = ClassDiagram(klass, self.config.mode) if len(project.modules) > 1: diff --git a/pylint/pyreverse/diagrams.py b/pylint/pyreverse/diagrams.py index 856f33f99cd..58da3215a2e 100644 --- a/pylint/pyreverse/diagrams.py +++ b/pylint/pyreverse/diagrams.py @@ -232,7 +232,8 @@ def module(self, name): def get_module(self, name, node): """return a module by its name, looking also for relative imports; raise - KeyError if not found.""" + KeyError if not found. + """ for mod in self.modules(): mod_name = mod.node.name if mod_name == name: diff --git a/pylint/pyreverse/printer.py b/pylint/pyreverse/printer.py index 326464de12e..2d7d7ceea44 100644 --- a/pylint/pyreverse/printer.py +++ b/pylint/pyreverse/printer.py @@ -72,7 +72,8 @@ def _dec_indent(self) -> None: @abstractmethod def _open_graph(self) -> None: """Emit the header lines, i.e. all boilerplate code that defines things like - layout etc.""" + layout etc. + """ def emit(self, line: str, force_newline: Optional[bool] = True) -> None: if force_newline and not line.endswith("\n"): diff --git a/pylint/pyreverse/utils.py b/pylint/pyreverse/utils.py index 066555b1e7f..89e0cd5bacb 100644 --- a/pylint/pyreverse/utils.py +++ b/pylint/pyreverse/utils.py @@ -80,7 +80,8 @@ def get_visibility(name): def is_abstract(node): """return true if the given class node correspond to an abstract class - definition.""" + definition. + """ return ABSTRACT.match(node.name) @@ -267,7 +268,8 @@ def get_annotation( def infer_node(node: Union[nodes.AssignAttr, nodes.AssignName]) -> set: """Return a set containing the node annotation if it exists otherwise return a set - of the inferred types using the NodeNG.infer method.""" + of the inferred types using the NodeNG.infer method. + """ ann = get_annotation(node) try: diff --git a/pylint/reporters/reports_handler_mix_in.py b/pylint/reporters/reports_handler_mix_in.py index 0c089b838e8..8f65397b5bf 100644 --- a/pylint/reporters/reports_handler_mix_in.py +++ b/pylint/reporters/reports_handler_mix_in.py @@ -26,7 +26,8 @@ class ReportsHandlerMixIn: """A mix-in class containing all the reports and stats manipulation related methods - for the main lint class.""" + for the main lint class. + """ def __init__(self) -> None: self._reports: ReportsDict = collections.defaultdict(list) diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py index 340d2b3dacd..fb7856fd6d5 100644 --- a/pylint/reporters/text.py +++ b/pylint/reporters/text.py @@ -212,7 +212,8 @@ def on_set_current_module(self, module: str, filepath: Optional[str]) -> None: def write_message(self, msg: Message) -> None: """Convenience method to write a formatted message with class default - template.""" + template. + """ self_dict = msg._asdict() for key in ("end_line", "end_column"): self_dict[key] = self_dict[key] or "" @@ -331,7 +332,8 @@ def _get_decoration(self, msg_id: str) -> MessageStyle: def handle_message(self, msg: Message) -> None: """manage message of different types, and colorize output using ansi escape - codes.""" + codes. + """ if msg.module not in self._modules: msg_style = self._get_decoration("S") if msg.module: diff --git a/pylint/reporters/ureports/base_writer.py b/pylint/reporters/ureports/base_writer.py index 7f8f28a5807..8c983ebeb5a 100644 --- a/pylint/reporters/ureports/base_writer.py +++ b/pylint/reporters/ureports/base_writer.py @@ -51,7 +51,8 @@ def format_children( self, layout: Union["EvaluationSection", "Paragraph", "Section"] ) -> None: """recurse on the layout children and call their accept method (see the Visitor - pattern)""" + pattern) + """ for child in getattr(layout, "children", ()): child.accept(self) diff --git a/pylint/testutils/functional/lint_module_output_update.py b/pylint/testutils/functional/lint_module_output_update.py index eb00464026b..0f76752ea80 100644 --- a/pylint/testutils/functional/lint_module_output_update.py +++ b/pylint/testutils/functional/lint_module_output_update.py @@ -15,7 +15,8 @@ class LintModuleOutputUpdate(LintModuleTest): """Class to be used if expected output files should be updated instead of - checked.""" + checked. + """ class TestDialect(csv.excel): """Dialect used by the csv writer.""" diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py index 487cbc38257..e121dc48130 100644 --- a/pylint/testutils/lint_module_test.py +++ b/pylint/testutils/lint_module_test.py @@ -260,7 +260,8 @@ def _check_output_text( actual_output: List[OutputLine], ) -> None: """This is a function because we want to be able to update the text in - LintModuleOutputUpdate.""" + LintModuleOutputUpdate. + """ assert expected_output == actual_output, self.error_msg_for_unequal_output( expected_output, actual_output ) diff --git a/pylint/testutils/output_line.py b/pylint/testutils/output_line.py index 68d5a26daeb..faedbacce2f 100644 --- a/pylint/testutils/output_line.py +++ b/pylint/testutils/output_line.py @@ -105,7 +105,8 @@ def _get_column(column: str) -> int: @staticmethod def _get_py38_none_value(value: T, check_endline: bool) -> Optional[T]: """Used to make end_line and end_column None as indicated by our version - compared to `min_pyver_end_position`.""" + compared to `min_pyver_end_position`. + """ if not check_endline: return None # pragma: no cover return value @@ -115,7 +116,8 @@ def from_csv( cls, row: Union[Sequence[str], str], check_endline: bool = True ) -> "OutputLine": """Create an OutputLine from a comma separated list (the functional tests - expected output .txt files).""" + expected output .txt files). + """ try: if isinstance(row, Sequence): column = cls._get_column(row[2]) diff --git a/pylint/utils/ast_walker.py b/pylint/utils/ast_walker.py index c4447812f2f..7bc7675ae09 100644 --- a/pylint/utils/ast_walker.py +++ b/pylint/utils/ast_walker.py @@ -53,7 +53,8 @@ def add_checker(self, checker): def walk(self, astroid): """Call visit events of astroid checkers for the given node, recurse on its - children, then leave events.""" + children, then leave events. + """ cid = astroid.__class__.__name__.lower() # Detect if the node is a new name for a deprecated alias. diff --git a/pylint/utils/file_state.py b/pylint/utils/file_state.py index 4e352a156b5..42a619f60a6 100644 --- a/pylint/utils/file_state.py +++ b/pylint/utils/file_state.py @@ -62,7 +62,8 @@ def _collect_block_lines( msg_state: MessageStateDict, ) -> None: """Recursively walk (depth first) AST to collect block level options line - numbers.""" + numbers. + """ for child in node.get_children(): self._collect_block_lines(msgs_store, child, msg_state) first = node.fromlineno diff --git a/pylint/utils/linterstats.py b/pylint/utils/linterstats.py index d4f46423e1f..cfed34e3e5f 100644 --- a/pylint/utils/linterstats.py +++ b/pylint/utils/linterstats.py @@ -156,7 +156,8 @@ def __str__(self) -> str: def init_single_module(self, module_name: str) -> None: """Use through PyLinter.set_current_module so PyLinter.current_name is - consistent.""" + consistent. + """ self.by_module[module_name] = ModuleStats( convention=0, error=0, fatal=0, info=0, refactor=0, statement=0, warning=0 ) @@ -308,7 +309,8 @@ def reset_message_count(self) -> None: def merge_stats(stats: List[LinterStats]): """Used to merge multiple stats objects into a new one when pylint is run in - parallel mode.""" + parallel mode. + """ merged = LinterStats() for stat in stats: merged.bad_names["argument"] += stat.bad_names["argument"] diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py index 23cca2a211e..1a07cf9ba8b 100644 --- a/pylint/utils/pragma_parser.py +++ b/pylint/utils/pragma_parser.py @@ -64,8 +64,7 @@ class PragmaParserError(Exception): """A class for exceptions thrown by pragma_parser module.""" def __init__(self, message: str, token: str) -> None: - """ - :args message: explain the reason why the exception has been thrown + """:args message: explain the reason why the exception has been thrown :args token: token concerned by the exception """ self.message = message diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index bf1d34f3689..1129909167c 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -123,7 +123,8 @@ def get_module_and_frameid(node): def get_rst_title(title, character): """Permit to get a title formatted as ReStructuredText test (underlined with a - chosen character).""" + chosen character). + """ return f"{title}\n{character * len(title)}\n" @@ -167,7 +168,8 @@ def tokenize_module(node: nodes.Module) -> List[tokenize.TokenInfo]: def register_plugins(linter, directory): """load all module and package in the given directory, looking for a 'register' - function in each one, used to register pylint checkers.""" + function in each one, used to register pylint checkers. + """ imported = {} for filename in os.listdir(directory): base, extension = os.path.splitext(filename) diff --git a/tests/checkers/unittest_design.py b/tests/checkers/unittest_design.py index 81e8d53b42a..09d4975bf21 100644 --- a/tests/checkers/unittest_design.py +++ b/tests/checkers/unittest_design.py @@ -25,7 +25,8 @@ class TestDesignChecker(CheckerTestCase): ) def test_too_many_ancestors_ignored_parents_are_skipped(self) -> None: """Make sure that classes listed in ``ignored-parents`` aren't counted by the - too- many-ancestors message.""" + too- many-ancestors message. + """ node = astroid.extract_node( """ diff --git a/tests/checkers/unittest_format.py b/tests/checkers/unittest_format.py index ab2c840ee60..6e0025a9f52 100644 --- a/tests/checkers/unittest_format.py +++ b/tests/checkers/unittest_format.py @@ -109,7 +109,8 @@ def testCheckKeywordParensHandlesUnnecessaryParens(self) -> None: def testNoSuperfluousParensWalrusOperatorIf(self) -> None: """Parenthesis change the meaning of assignment in the walrus operator and so - are not always superfluous:""" + are not always superfluous: + """ cases = [ ("if (odd := is_odd(i))\n"), ("not (foo := 5)\n"), @@ -177,7 +178,8 @@ def test_encoding_token(self) -> None: def test_disable_global_option_end_of_line() -> None: """Test for issue with disabling tokenizer messages that extend beyond the scope of - the ast tokens.""" + the ast tokens. + """ file_ = tempfile.NamedTemporaryFile("w", delete=False) with file_: file_.write( diff --git a/tests/config/unittest_config.py b/tests/config/unittest_config.py index f767643f425..80f895000d0 100644 --- a/tests/config/unittest_config.py +++ b/tests/config/unittest_config.py @@ -77,7 +77,8 @@ def test__regexp_csv_validator_invalid() -> None: class TestPyLinterOptionSetters(CheckerTestCase): """Class to check the set_config decorator and get_global_option util for options - declared in PyLinter.""" + declared in PyLinter. + """ class Checker(BaseChecker): name = "checker" diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py index c23c406e1fd..e3fc6bff922 100644 --- a/tests/lint/unittest_lint.py +++ b/tests/lint/unittest_lint.py @@ -811,7 +811,8 @@ def should_analyze_file(modname: str, path: str, is_argument: bool = False) -> b def test_custom_should_analyze_file() -> None: """Check that we can write custom should_analyze_file that work even for - arguments.""" + arguments. + """ package_dir = os.path.join(REGRTEST_DATA_DIR, "bad_package") wrong_file = os.path.join(package_dir, "wrong.py") diff --git a/tests/primer/test_primer_stdlib.py b/tests/primer/test_primer_stdlib.py index 089f2ee0f2e..72f5cdfabf1 100644 --- a/tests/primer/test_primer_stdlib.py +++ b/tests/primer/test_primer_stdlib.py @@ -47,7 +47,8 @@ def test_primer_stdlib_no_crash( test_module_location: str, test_module_name: str, capsys: CaptureFixture ) -> None: """Test that pylint does not produce any crashes or fatal errors on stdlib - modules.""" + modules. + """ __tracebackhide__ = True # pylint: disable=unused-variable os.chdir(test_module_location) with _patch_stdout(io.StringIO()): diff --git a/tests/pyreverse/test_diadefs.py b/tests/pyreverse/test_diadefs.py index 2730468bff0..41b92dfe354 100644 --- a/tests/pyreverse/test_diadefs.py +++ b/tests/pyreverse/test_diadefs.py @@ -128,7 +128,8 @@ def test_functional_relation_extraction( self, default_config: PyreverseConfig, get_project: Callable ) -> None: """functional test of relations extraction; different classes possibly in - different modules.""" + different modules. + """ # XXX should be catching pyreverse environment problem but doesn't # pyreverse doesn't extract the relations but this test ok project = get_project("data") diff --git a/tests/pyreverse/test_utils.py b/tests/pyreverse/test_utils.py index 23eedcf8806..e126966afbe 100644 --- a/tests/pyreverse/test_utils.py +++ b/tests/pyreverse/test_utils.py @@ -85,7 +85,8 @@ class A: @patch("astroid.node_classes.NodeNG.infer", side_effect=astroid.InferenceError) def test_infer_node_1(mock_infer: Any, mock_get_annotation: Any) -> None: """Return set() when astroid.InferenceError is raised and an annotation has not been - returned.""" + returned. + """ mock_get_annotation.return_value = None node = astroid.extract_node("a: str = 'mystr'") mock_infer.return_value = "x" @@ -97,7 +98,8 @@ def test_infer_node_1(mock_infer: Any, mock_get_annotation: Any) -> None: @patch("astroid.node_classes.NodeNG.infer") def test_infer_node_2(mock_infer: Any, mock_get_annotation: Any) -> None: """Return set(node.infer()) when InferenceError is not raised and an annotation has - not been returned.""" + not been returned. + """ mock_get_annotation.return_value = None node = astroid.extract_node("a: str = 'mystr'") mock_infer.return_value = "x" @@ -107,7 +109,8 @@ def test_infer_node_2(mock_infer: Any, mock_get_annotation: Any) -> None: def test_infer_node_3() -> None: """Return a set containing a nodes.ClassDef object when the attribute has a type - annotation.""" + annotation. + """ node = astroid.extract_node( """ class Component: diff --git a/tests/test_check_parallel.py b/tests/test_check_parallel.py index 1990d26ddae..e0b5c5f487e 100644 --- a/tests/test_check_parallel.py +++ b/tests/test_check_parallel.py @@ -242,7 +242,8 @@ def test_worker_check_single_file_no_checkers(self) -> None: def test_worker_check_sequential_checker(self) -> None: """Same as test_worker_check_single_file_no_checkers with - SequentialTestChecker.""" + SequentialTestChecker. + """ linter = PyLinter(reporter=Reporter()) worker_initialize(linter=dill.dumps(linter)) diff --git a/tests/test_func.py b/tests/test_func.py index 17c64c9ccce..7cc41856dc9 100644 --- a/tests/test_func.py +++ b/tests/test_func.py @@ -39,7 +39,8 @@ def exception_str(self, ex) -> str: # pylint: disable=unused-argument """function used to replace default __str__ method of exception instances This - function is not typed because it is legacy code.""" + function is not typed because it is legacy code. + """ return f"in {ex.file}\n:: {', '.join(ex.args)}" diff --git a/tests/test_import_graph.py b/tests/test_import_graph.py index 62772cfd427..bede4c903ac 100644 --- a/tests/test_import_graph.py +++ b/tests/test_import_graph.py @@ -74,7 +74,8 @@ def test_dependencies_graph(dest: str) -> None: ) def test_missing_graphviz(filename: str) -> None: """Raises if graphviz is not installed, and defaults to png if no extension - given.""" + given. + """ with pytest.raises(RuntimeError, match=r"Cannot generate `graph\.png`.*"): imports._dependencies_graph(filename, {"a": {"b", "c"}, "b": {"c"}}) diff --git a/tests/test_regr.py b/tests/test_regr.py index 5b1bce0a006..caf64d929fc 100644 --- a/tests/test_regr.py +++ b/tests/test_regr.py @@ -51,7 +51,8 @@ def disable(): @pytest.fixture def finalize_linter(linter: PyLinter) -> Iterator[PyLinter]: """Call reporter.finalize() to clean up pending messages if a test finished - badly.""" + badly. + """ yield linter linter.reporter = cast( # Due to fixture testutils.GenericTestReporter, linter.reporter diff --git a/tests/test_self.py b/tests/test_self.py index c0a3cc93e01..6635c1a73e7 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -184,7 +184,8 @@ def _test_output_file( self, args: List[str], filename: LocalPath, expected_output: str ) -> None: """Run Pylint with the ``output`` option set (must be included in the ``args`` - passed to this method!) and check the file content afterwards.""" + passed to this method!) and check the file content afterwards. + """ out = StringIO() self._run_pylint(args, out=out) cmdline_output = out.getvalue() diff --git a/tests/testutils/test_output_line.py b/tests/testutils/test_output_line.py index cb183ee46b1..bfb879cd1ec 100644 --- a/tests/testutils/test_output_line.py +++ b/tests/testutils/test_output_line.py @@ -90,7 +90,8 @@ def test_output_line_from_message(message: Callable) -> None: @pytest.mark.parametrize("confidence", [HIGH, INFERENCE]) def test_output_line_to_csv(confidence: Confidence, message: Callable) -> None: """Test that the OutputLine NamedTuple is instantiated correctly with from_msg and - then converted to csv.""" + then converted to csv. + """ output_line = OutputLine.from_msg(message(confidence), True) csv = output_line.to_csv() expected_column = "2" if PY38_PLUS else "0" diff --git a/tests/utils/unittest_utils.py b/tests/utils/unittest_utils.py index ac13648734c..3d2d8b53170 100644 --- a/tests/utils/unittest_utils.py +++ b/tests/utils/unittest_utils.py @@ -26,7 +26,8 @@ def test_decoding_stream_unknown_encoding() -> None: """decoding_stream should fall back to *some* decoding when given an unknown - encoding.""" + encoding. + """ binary_io = io.BytesIO(b"foo\nbar") stream = utils.decoding_stream(binary_io, "garbage-encoding") # should still act like a StreamReader