summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/custom.py3
-rw-r--r--examples/deprecation_checker.py3
-rw-r--r--pylint/checkers/base.py15
-rw-r--r--pylint/checkers/base_checker.py9
-rw-r--r--pylint/checkers/classes/class_checker.py10
-rw-r--r--pylint/checkers/classes/special_methods_checker.py3
-rw-r--r--pylint/checkers/ellipsis_checker.py3
-rw-r--r--pylint/checkers/exceptions.py3
-rw-r--r--pylint/checkers/format.py29
-rw-r--r--pylint/checkers/logging.py7
-rw-r--r--pylint/checkers/newstyle.py3
-rw-r--r--pylint/checkers/refactoring/implicit_booleaness_checker.py3
-rw-r--r--pylint/checkers/refactoring/recommendation_checker.py3
-rw-r--r--pylint/checkers/refactoring/refactoring_checker.py28
-rw-r--r--pylint/checkers/similar.py38
-rw-r--r--pylint/checkers/spelling.py10
-rw-r--r--pylint/checkers/strings.py9
-rw-r--r--pylint/checkers/typecheck.py17
-rw-r--r--pylint/checkers/unsupported_version.py3
-rw-r--r--pylint/checkers/utils.py30
-rw-r--r--pylint/checkers/variables.py29
-rw-r--r--pylint/config/configuration_mixin.py3
-rw-r--r--pylint/config/option_manager_mixin.py3
-rwxr-xr-xpylint/epylint.py3
-rw-r--r--pylint/extensions/_check_docs_utils.py6
-rw-r--r--pylint/extensions/comparison_placement.py3
-rw-r--r--pylint/extensions/docparams.py6
-rw-r--r--pylint/extensions/mccabe.py3
-rw-r--r--pylint/extensions/overlapping_exceptions.py3
-rw-r--r--pylint/lint/expand_modules.py3
-rw-r--r--pylint/lint/pylinter.py12
-rw-r--r--pylint/message/message_id_store.py6
-rw-r--r--pylint/pyreverse/__init__.py4
-rw-r--r--pylint/pyreverse/diadefslib.py3
-rw-r--r--pylint/pyreverse/dot_printer.py4
-rw-r--r--pylint/pyreverse/inspector.py3
-rw-r--r--pylint/pyreverse/main.py3
-rw-r--r--pylint/pyreverse/mermaidjs_printer.py4
-rw-r--r--pylint/pyreverse/plantuml_printer.py4
-rw-r--r--pylint/pyreverse/printer.py4
-rw-r--r--pylint/pyreverse/utils.py6
-rw-r--r--pylint/reporters/multi_reporter.py3
-rw-r--r--pylint/reporters/text.py3
-rw-r--r--pylint/testutils/lint_module_test.py3
-rw-r--r--pylint/testutils/output_line.py3
-rw-r--r--pylint/testutils/pyreverse.py3
-rw-r--r--pylint/utils/pragma_parser.py15
-rw-r--r--script/bump_changelog.py4
-rw-r--r--tests/benchmark/test_baseline_benchmarks.py33
-rw-r--r--tests/checkers/unittest_design.py3
-rw-r--r--tests/checkers/unittest_format.py6
-rw-r--r--tests/checkers/unittest_stdlib.py3
-rw-r--r--tests/checkers/unittest_variables.py3
-rw-r--r--tests/config/test_functional_config_loading.py3
-rw-r--r--tests/config/unittest_config.py6
-rw-r--r--tests/pyreverse/test_diadefs.py3
-rw-r--r--tests/pyreverse/test_inspector.py4
-rw-r--r--tests/pyreverse/test_printer_factory.py4
-rw-r--r--tests/pyreverse/test_utils.py3
-rw-r--r--tests/pyreverse/test_writer.py4
-rw-r--r--tests/test_check_parallel.py6
-rw-r--r--tests/test_func.py3
-rw-r--r--tests/test_self.py7
-rw-r--r--tests/unittest_reporting.py3
64 files changed, 208 insertions, 264 deletions
diff --git a/examples/custom.py b/examples/custom.py
index 695f77d20..d4376fc4e 100644
--- a/examples/custom.py
+++ b/examples/custom.py
@@ -52,7 +52,8 @@ class MyAstroidChecker(BaseChecker):
def visit_call(self, node: nodes.Call) -> None:
"""Called when a :class:`.nodes.Call` node is visited.
- See :mod:`astroid` for the description of available nodes."""
+ See :mod:`astroid` for the description of available nodes.
+ """
if not (
isinstance(node.func, nodes.Attribute)
and isinstance(node.func.expr, nodes.Name)
diff --git a/examples/deprecation_checker.py b/examples/deprecation_checker.py
index d3dca4e07..79a728537 100644
--- a/examples/deprecation_checker.py
+++ b/examples/deprecation_checker.py
@@ -1,5 +1,4 @@
-"""
-Example checker detecting deprecated functions/methods. Following example searches for usages of
+"""Example checker detecting deprecated functions/methods. Following example searches for usages of
deprecated function `deprecated_function` and deprecated method `MyClass.deprecated_method`
from module mymodule:
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 39ab5d673..c1eefab92 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -103,7 +103,8 @@ else:
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."""
+ in method names.
+ """
ANY: Pattern[str] = re.compile(".*")
CLASS_NAME_RGX: Pattern[str] = ANY
@@ -278,8 +279,7 @@ def in_nested_list(nested_list, obj):
def _get_break_loop_node(break_node):
- """
- Returns the loop node that holds the break node in arguments.
+ """Returns the loop node that holds the break node in arguments.
Args:
break_node (astroid.Break): the break node of interest.
@@ -300,8 +300,7 @@ def _get_break_loop_node(break_node):
def _loop_exits_early(loop):
- """
- Returns true if a loop may end with a break statement.
+ """Returns true if a loop may end with a break statement.
Args:
loop (astroid.For, astroid.While): the loop node inspected.
@@ -389,8 +388,7 @@ def _determine_function_name_type(node: nodes.FunctionDef, config=None):
def _has_abstract_methods(node):
- """
- Determine if the given `node` has abstract methods.
+ """Determine if the given `node` has abstract methods.
The methods should be made abstract by decorating them
with `abc` decorators.
@@ -1496,7 +1494,8 @@ class BasicChecker(_BasicChecker):
"""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."""
+ a 'try...finally' block we skip the whole check.
+ """
# if self._tryfinallys is empty, we're not an in try...finally block
if not self._tryfinallys:
return
diff --git a/pylint/checkers/base_checker.py b/pylint/checkers/base_checker.py
index 8fe44a2e2..5a6efd20c 100644
--- a/pylint/checkers/base_checker.py
+++ b/pylint/checkers/base_checker.py
@@ -50,7 +50,8 @@ class BaseChecker(OptionsProviderMixIn):
def __init__(self, linter=None):
"""checker instances should have the linter as argument
- :param ILinter linter: is an object implementing ILinter."""
+ :param ILinter linter: is an object implementing ILinter.
+ """
if self.name is not None:
self.name = self.name.lower()
super().__init__()
@@ -67,7 +68,8 @@ class BaseChecker(OptionsProviderMixIn):
def __str__(self):
"""This might be incomplete because multiple class inheriting BaseChecker
- can have the same name. Cf MessageHandlerMixIn.get_full_documentation()"""
+ can have the same name. Cf MessageHandlerMixIn.get_full_documentation()
+ """
return self.get_full_documentation(
msgs=self.msgs, options=self.options_and_values(), reports=self.reports
)
@@ -132,7 +134,8 @@ class BaseChecker(OptionsProviderMixIn):
checker.
:raises InvalidMessageError: If the checker id in the messages are not
- always the same."""
+ always the same.
+ """
checker_id = None
existing_ids = []
for message in self.messages:
diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py
index b76e10e43..fce2f7025 100644
--- a/pylint/checkers/classes/class_checker.py
+++ b/pylint/checkers/classes/class_checker.py
@@ -186,8 +186,7 @@ _DEFAULT_MISSING = _DefaultMissing()
def _has_different_parameters_default_value(original, overridden):
- """
- Check if original and overridden methods arguments have different default values
+ """Check if original and overridden methods arguments have different default values
Return True if one of the overridden arguments has a default
value different from the default value of the original argument
@@ -821,8 +820,7 @@ a metaclass class method.",
pass
def _check_proper_bases(self, node):
- """
- Detect that a class inherits something which is not
+ """Detect that a class inherits something which is not
a class or a type.
"""
for base in node.bases:
@@ -1655,9 +1653,7 @@ a metaclass class method.",
@staticmethod
def _is_called_inside_special_method(node: nodes.NodeNG) -> bool:
- """
- Returns true if the node is located inside a special (aka dunder) method
- """
+ """Returns true if the node is located inside a special (aka dunder) method"""
try:
frame_name = node.frame().name
except AttributeError:
diff --git a/pylint/checkers/classes/special_methods_checker.py b/pylint/checkers/classes/special_methods_checker.py
index 51c52b3ae..f26823007 100644
--- a/pylint/checkers/classes/special_methods_checker.py
+++ b/pylint/checkers/classes/special_methods_checker.py
@@ -21,8 +21,7 @@ NEXT_METHOD = "__next__"
def _safe_infer_call_result(node, caller, context=None):
- """
- Safely infer the return value of a function.
+ """Safely infer the return value of a function.
Returns None if inference failed or if there is some ambiguity (more than
one node has been inferred). Otherwise, returns inferred value.
diff --git a/pylint/checkers/ellipsis_checker.py b/pylint/checkers/ellipsis_checker.py
index e5d4c4ecd..af8715ed5 100644
--- a/pylint/checkers/ellipsis_checker.py
+++ b/pylint/checkers/ellipsis_checker.py
@@ -1,5 +1,4 @@
-"""Ellipsis checker for Python code
-"""
+"""Ellipsis checker for Python code"""
from typing import TYPE_CHECKING
from astroid import nodes
diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py
index 0d60b0a39..eafbafa2b 100644
--- a/pylint/checkers/exceptions.py
+++ b/pylint/checkers/exceptions.py
@@ -57,8 +57,7 @@ def _builtin_exceptions():
def _annotated_unpack_infer(stmt, context=None):
- """
- Recursively generate nodes inferred by the given statement.
+ """Recursively generate nodes inferred by the given statement.
If the inferred value is a list or a tuple, recurse on the elements.
Returns an iterator which yields tuples in the format
('original node', 'inferred node').
diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py
index 17a50911c..f38944ded 100644
--- a/pylint/checkers/format.py
+++ b/pylint/checkers/format.py
@@ -669,9 +669,7 @@ class FormatChecker(BaseTokenChecker):
self._visited_lines[line] = 2
def check_line_ending(self, line: str, i: int) -> None:
- """
- Check that the final newline is not missing and that there is no trailing whitespace.
- """
+ """Check that the final newline is not missing and that there is no trailing whitespace."""
if not line.endswith("\n"):
self.add_message("missing-final-newline", line=i)
return
@@ -683,9 +681,7 @@ class FormatChecker(BaseTokenChecker):
)
def check_line_length(self, line: str, i: int, checker_off: bool) -> None:
- """
- Check that the line length is less than the authorized value
- """
+ """Check that the line length is less than the authorized value"""
max_chars = self.config.max_line_length
ignore_long_line = self.config.ignore_long_lines
line = line.rstrip()
@@ -697,9 +693,7 @@ class FormatChecker(BaseTokenChecker):
@staticmethod
def remove_pylint_option_from_lines(options_pattern_obj) -> str:
- """
- Remove the `# pylint ...` pattern from lines
- """
+ """Remove the `# pylint ...` pattern from lines"""
lines = options_pattern_obj.string
purged_lines = (
lines[: options_pattern_obj.start(1)].rstrip()
@@ -709,9 +703,7 @@ class FormatChecker(BaseTokenChecker):
@staticmethod
def is_line_length_check_activated(pylint_pattern_match_object) -> bool:
- """
- Return true if the line length check is activated
- """
+ """Return true if the line length check is activated"""
try:
for pragma in parse_pragma(pylint_pattern_match_object.group(2)):
if pragma.action == "disable" and "line-too-long" in pragma.messages:
@@ -723,9 +715,7 @@ class FormatChecker(BaseTokenChecker):
@staticmethod
def specific_splitlines(lines: str) -> List[str]:
- """
- Split lines according to universal newlines except those in a specific sets
- """
+ """Split lines according to universal newlines except those in a specific sets"""
unsplit_ends = {
"\v",
"\x0b",
@@ -749,11 +739,10 @@ class FormatChecker(BaseTokenChecker):
return res
def check_lines(self, lines: str, lineno: int) -> None:
- """
- Check lines have :
- - a final newline
- - no trailing whitespace
- - less than a maximum number of characters
+ """Check lines have :
+ - a final newline
+ - no trailing whitespace
+ - less than a maximum number of characters
"""
# we're first going to do a rough check whether any lines in this set
# go over the line limit. If none of them do, then we don't need to
diff --git a/pylint/checkers/logging.py b/pylint/checkers/logging.py
index 19e04c7d1..4c4401741 100644
--- a/pylint/checkers/logging.py
+++ b/pylint/checkers/logging.py
@@ -23,8 +23,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""checker for use of Python logging
-"""
+"""checker for use of Python logging"""
import string
from typing import TYPE_CHECKING, Set
@@ -295,9 +294,7 @@ class LoggingChecker(checkers.BaseChecker):
@staticmethod
def _is_operand_literal_str(operand):
- """
- Return True if the operand in argument is a literal string
- """
+ """Return True if the operand in argument is a literal string"""
return isinstance(operand, nodes.Const) and operand.name == "str"
def _check_call_func(self, node: nodes.Call):
diff --git a/pylint/checkers/newstyle.py b/pylint/checkers/newstyle.py
index b19a5c7ef..45b4409d8 100644
--- a/pylint/checkers/newstyle.py
+++ b/pylint/checkers/newstyle.py
@@ -20,8 +20,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""check for new / old style related problems
-"""
+"""check for new / old style related problems"""
from typing import TYPE_CHECKING
import astroid
diff --git a/pylint/checkers/refactoring/implicit_booleaness_checker.py b/pylint/checkers/refactoring/implicit_booleaness_checker.py
index 29277e3a2..6167e3e88 100644
--- a/pylint/checkers/refactoring/implicit_booleaness_checker.py
+++ b/pylint/checkers/refactoring/implicit_booleaness_checker.py
@@ -129,7 +129,8 @@ class ImplicitBooleanessChecker(checkers.BaseChecker):
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):`"""
+ e.g. `if not len(S):`
+ """
if (
isinstance(node, nodes.UnaryOp)
and node.op == "not"
diff --git a/pylint/checkers/refactoring/recommendation_checker.py b/pylint/checkers/refactoring/recommendation_checker.py
index 3094ffd07..785e37fdd 100644
--- a/pylint/checkers/refactoring/recommendation_checker.py
+++ b/pylint/checkers/refactoring/recommendation_checker.py
@@ -337,7 +337,8 @@ class RecommendationChecker(checkers.BaseChecker):
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 40a72a53f..a18257456 100644
--- a/pylint/checkers/refactoring/refactoring_checker.py
+++ b/pylint/checkers/refactoring/refactoring_checker.py
@@ -118,8 +118,7 @@ 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
+ """Checks if one of the node's parents is a ``nodes.With`` node and that the node itself is located
somewhere under its ``items``.
"""
frame = node.frame()
@@ -135,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."""
+ construct which would ensure that its __exit__ method is called.
+ """
callables_taking_care_of_exit = frozenset(
(
"contextlib._BaseExitStack.enter_context",
@@ -152,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."""
+ if they are not used in a ``with`` block later on.
+ """
module_scope: Dict[str, nodes.NodeNG] = {}
class_scope: Dict[str, nodes.NodeNG] = {}
@@ -1278,7 +1279,8 @@ class RefactoringChecker(checkers.BaseTokenChecker):
reverse for AND
2) False values in OR expressions are only relevant if all values are
- false, and the reverse for AND"""
+ false, and the reverse for AND
+ """
simplified_values = []
for subnode in values:
@@ -1299,7 +1301,8 @@ class RefactoringChecker(checkers.BaseTokenChecker):
"""Attempts to simplify a boolean operation
Recursively applies simplification on the operator terms,
- and keeps track of whether reductions have been made."""
+ and keeps track of whether reductions have been made.
+ """
children = list(bool_op.get_children())
intermediate = [
self._simplify_boolean_operation(child)
@@ -1320,7 +1323,8 @@ class RefactoringChecker(checkers.BaseTokenChecker):
"""Check if a boolean condition can be simplified.
Variables will not be simplified, even in the value can be inferred,
- and expressions like '3 + 4' will remain expanded."""
+ and expressions like '3 + 4' will remain expanded.
+ """
if not utils.is_test_condition(node):
return
@@ -1506,8 +1510,7 @@ class RefactoringChecker(checkers.BaseTokenChecker):
self.add_message("use-dict-literal", node=node)
def _check_consider_using_join(self, aug_assign):
- """
- We start with the augmented assignment and work our way upwards.
+ """We start with the augmented assignment and work our way upwards.
Names of variables for nodes if match successful:
result = '' # assign
for number in ['1', '2', '3'] # for_loop
@@ -1630,8 +1633,7 @@ class RefactoringChecker(checkers.BaseTokenChecker):
@staticmethod
def _is_and_or_ternary(node):
- """
- Returns true if node is 'condition and true_value or false_value' form.
+ """Returns true if node is 'condition and true_value or false_value' form.
All of: condition, true_value and false_value should not be a complex boolean expression
"""
@@ -1793,9 +1795,7 @@ class RefactoringChecker(checkers.BaseTokenChecker):
@staticmethod
def _has_return_in_siblings(node: nodes.NodeNG) -> bool:
- """
- Returns True if there is at least one return in the node's siblings
- """
+ """Returns True if there is at least one return in the node's siblings"""
next_sibling = node.next_sibling()
while next_sibling:
if isinstance(next_sibling, nodes.Return):
diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py
index 51ec27c0b..ab7263135 100644
--- a/pylint/checkers/similar.py
+++ b/pylint/checkers/similar.py
@@ -108,8 +108,7 @@ STREAM_TYPES = Union[TextIO, BufferedReader, BytesIO]
class CplSuccessiveLinesLimits:
- """
- This class holds a couple of SuccessiveLinesLimits objects, one for each file compared,
+ """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
"""
@@ -133,9 +132,7 @@ CplIndexToCplLines_T = Dict["LineSetStartCouple", CplSuccessiveLinesLimits]
class LinesChunk:
- """
- The LinesChunk object computes and stores the hash of some consecutive stripped lines of a lineset.
- """
+ """The LinesChunk object computes and stores the hash of some consecutive stripped lines of a lineset."""
__slots__ = ("_fileid", "_index", "_hash")
@@ -170,8 +167,7 @@ class LinesChunk:
class SuccessiveLinesLimits:
- """
- A class to handle the numbering of begin and end of successive lines.
+ """A class to handle the numbering of begin and end of successive lines.
:note: Only the end line number can be updated.
"""
@@ -199,9 +195,7 @@ class SuccessiveLinesLimits:
class LineSetStartCouple(NamedTuple):
- """
- Indices in both linesets that mark the beginning of successive lines
- """
+ """Indices in both linesets that mark the beginning of successive lines"""
fst_lineset_index: Index
snd_lineset_index: Index
@@ -235,8 +229,7 @@ LinesChunkLimits_T = Tuple["LineSet", LineNumber, LineNumber]
def hash_lineset(
lineset: "LineSet", min_common_lines: int = DEFAULT_MIN_SIMILARITY_LINE
) -> Tuple[HashToIndex_T, IndexToLines_T]:
- """
- Return two dicts. The first associates the hash of successive stripped lines of a lineset
+ """Return two dicts. The first associates the hash of successive stripped lines of a lineset
to the indices of the starting lines.
The second dict, associates the index of the starting line in the lineset's stripped lines to the
couple [start, end] lines number in the corresponding file.
@@ -275,8 +268,7 @@ def hash_lineset(
def remove_successives(all_couples: CplIndexToCplLines_T) -> None:
- """
- Removes all successive entries in the dictionary in argument
+ """Removes all successive entries in the dictionary in argument
:param all_couples: collection that has to be cleaned up from successives entries.
The keys are couples of indices that mark the beginning of common entries
@@ -325,8 +317,7 @@ def filter_noncode_lines(
stindex_2: Index,
common_lines_nb: int,
) -> int:
- """
- Return the effective number of common lines between lineset1 and lineset2 filtered from non code lines, that is to say the number of
+ """Return the effective number of common lines between lineset1 and lineset2 filtered from non code lines, that is to say the number of
common successive stripped lines except those that do not contain code (for example a ligne with only an
ending parathensis)
@@ -477,8 +468,7 @@ class Similar:
def _find_common(
self, lineset1: "LineSet", lineset2: "LineSet"
) -> Generator[Commonality, None, None]:
- """
- Find similarities in the two given linesets.
+ """Find similarities in the two given linesets.
This the core of the algorithm.
The idea is to compute the hashes of a minimal number of successive lines of each lineset and then compare the hashes.
@@ -562,7 +552,8 @@ class Similar:
def combine_mapreduce_data(self, linesets_collection):
"""Reduces and recombines data into a format that we can report on
- The partner function of get_map_data()"""
+ The partner function of get_map_data()
+ """
self.linesets = [line for lineset in linesets_collection for line in lineset]
@@ -573,8 +564,7 @@ def stripped_lines(
ignore_imports: bool,
ignore_signatures: bool,
) -> List[LineSpecifs]:
- """
- Return tuples of line/line number/line type with leading/trailing whitespace and any ignored code features removed
+ """Return tuples of line/line number/line type with leading/trailing whitespace and any ignored code features removed
:param lines: a collection of lines
:param ignore_comments: if true, any comment in the lines collection is removed from the result
@@ -664,8 +654,7 @@ def stripped_lines(
@functools.total_ordering
class LineSet:
- """
- Holds and indexes all the lines of a single source file.
+ """Holds and indexes all the lines of a single source file.
Allows for correspondence between real lines of the source file and stripped ones, which
are the real ones from which undesired patterns have been removed.
"""
@@ -871,7 +860,8 @@ class SimilarChecker(BaseChecker, Similar, MapReduceMixin):
def reduce_map_data(self, linter, data):
"""Reduces and recombines data into a format that we can report on
- The partner function of get_map_data()"""
+ The partner function of get_map_data()
+ """
recombined = SimilarChecker(linter)
recombined.min_lines = self.min_lines
recombined.ignore_comments = self.ignore_comments
diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py
index 012c396de..752eb83e3 100644
--- a/pylint/checkers/spelling.py
+++ b/pylint/checkers/spelling.py
@@ -28,8 +28,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""Checker for spelling errors in comments and docstrings.
-"""
+"""Checker for spelling errors in comments and docstrings."""
import os
import re
import tokenize
@@ -147,9 +146,7 @@ class SphinxDirectives(RegExFilter):
class ForwardSlashChunker(Chunker):
- """
- This chunker allows splitting words like 'before/after' into 'before' and 'after'
- """
+ """This chunker allows splitting words like 'before/after' into 'before' and 'after'"""
def next(self):
while True:
@@ -194,7 +191,8 @@ def _strip_code_flanked_in_backticks(line: str) -> str:
"""Alter line so code flanked in backticks is ignored.
Pyenchant automatically strips backticks when parsing tokens,
- so this cannot be done at the individual filter level."""
+ so this cannot be done at the individual filter level.
+ """
def replace_code_but_leave_surrounding_characters(match_obj) -> str:
return match_obj.group(1) + match_obj.group(5)
diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py
index e4dcfc831..458c96fe6 100644
--- a/pylint/checkers/strings.py
+++ b/pylint/checkers/strings.py
@@ -34,8 +34,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""Checker for string formatting operations.
-"""
+"""Checker for string formatting operations."""
import collections
import numbers
@@ -540,8 +539,7 @@ class StringFormatChecker(BaseChecker):
self._check_new_format_specifiers(node, fields, named_arguments)
def _check_new_format_specifiers(self, node, fields, named):
- """
- Check attribute and index access in the format
+ """Check attribute and index access in the format
string ("{0.a}" and "{0[a]}").
"""
for key, specifiers in fields:
@@ -934,8 +932,7 @@ def register(linter: "PyLinter") -> None:
def str_eval(token):
- """
- Mostly replicate `ast.literal_eval(token)` manually to avoid any performance hit.
+ """Mostly replicate `ast.literal_eval(token)` manually to avoid any performance hit.
This supports f-strings, contrary to `ast.literal_eval`.
We have to support all string literal notations:
https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index a2239469a..c0a7725f9 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -55,8 +55,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""try to find more bugs in the code using astroid inference capabilities
-"""
+"""try to find more bugs in the code using astroid inference capabilities"""
import fnmatch
import heapq
@@ -1137,9 +1136,7 @@ accessed. Python regular expressions are accepted.",
"non-str-assignment-to-dunder-name",
)
def visit_assign(self, node: nodes.Assign) -> None:
- """
- Process assignments in the AST.
- """
+ """Process assignments in the AST."""
self._check_assignment_from_function_call(node)
self._check_dundername_is_string(node)
@@ -1193,9 +1190,7 @@ accessed. Python regular expressions are accepted.",
self.add_message("assignment-from-none", node=node)
def _check_dundername_is_string(self, node):
- """
- Check a string is assigned to self.__name__
- """
+ """Check a string is assigned to self.__name__"""
# Check the left-hand side of the assignment is <something>.__name__
lhs = node.targets[0]
@@ -1216,8 +1211,7 @@ accessed. Python regular expressions are accepted.",
self.add_message("non-str-assignment-to-dunder-name", node=node)
def _check_uninferable_call(self, node):
- """
- Check that the given uninferable Call node does not
+ """Check that the given uninferable Call node does not
call an actual function.
"""
if not isinstance(node.func, nodes.Attribute):
@@ -1979,8 +1973,7 @@ accessed. Python regular expressions are accepted.",
class IterableChecker(BaseChecker):
- """
- Checks for non-iterables used in an iterable context.
+ """Checks for non-iterables used in an iterable context.
Contexts include:
- for-statement
- starargs in function call
diff --git a/pylint/checkers/unsupported_version.py b/pylint/checkers/unsupported_version.py
index 64078aa68..ada104ab9 100644
--- a/pylint/checkers/unsupported_version.py
+++ b/pylint/checkers/unsupported_version.py
@@ -68,7 +68,8 @@ class UnsupportedVersionChecker(BaseChecker):
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"""
+ py-version is lower than 3.8
+ """
if self._py38_plus:
return
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index cd72e38ee..c20342c82 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -57,8 +57,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""some functions that may be useful for various checkers
-"""
+"""some functions that may be useful for various checkers"""
import builtins
import itertools
import numbers
@@ -476,7 +475,8 @@ def assign_parent(node: nodes.NodeNG) -> nodes.NodeNG:
def overrides_a_method(class_node: nodes.ClassDef, name: str) -> bool:
"""return True if <name> is a method overridden from an ancestor
- which is not the base object class"""
+ which is not the base object class
+ """
for ancestor in class_node.ancestors():
if ancestor.name == "object":
continue
@@ -501,7 +501,8 @@ class IncompleteFormatString(Exception):
class UnsupportedFormatCharacter(Exception):
"""A format character in a format string is not one of the supported
- format characters."""
+ format characters.
+ """
def __init__(self, index):
super().__init__(index)
@@ -625,8 +626,7 @@ def collect_string_fields(format_string) -> Iterable[Optional[str]]:
def parse_format_method_string(
format_string: str,
) -> Tuple[List[Tuple[str, List[Tuple[bool, str]]]], int, int]:
- """
- Parses a PEP 3101 format string, returning a tuple of
+ """Parses a PEP 3101 format string, returning a tuple of
(keyword_arguments, 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
@@ -733,8 +733,7 @@ def get_argument_from_call(
def inherit_from_std_ex(node: nodes.NodeNG) -> bool:
- """
- Return whether the given class node is subclass of
+ """Return whether the given class node is subclass of
exceptions.Exception.
"""
ancestors = node.ancestors() if hasattr(node, "ancestors") else []
@@ -746,8 +745,7 @@ def inherit_from_std_ex(node: nodes.NodeNG) -> bool:
def error_of_type(handler: nodes.ExceptHandler, error_type) -> bool:
- """
- Check if the given exception handler catches
+ """Check if the given exception handler catches
the given error_type.
The *handler* parameter is a node, representing an ExceptHandler node.
@@ -908,8 +906,7 @@ def uninferable_final_decorators(
def unimplemented_abstract_methods(
node: nodes.ClassDef, is_abstract_cb: nodes.FunctionDef = None
) -> Dict[str, nodes.NodeNG]:
- """
- Get the unimplemented abstract methods for the given *node*.
+ """Get the unimplemented abstract methods for the given *node*.
A method can be considered abstract if the callback *is_abstract_cb*
returns a ``True`` value. The check defaults to verifying that
@@ -1368,8 +1365,7 @@ def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
def get_node_last_lineno(node: nodes.NodeNG) -> int:
- """
- Get the last lineno of the given node. For a simple statement this will just be node.lineno,
+ """Get the last lineno of the given node. For a simple statement this will just be node.lineno,
but for a node that has child statements (e.g. a method) this will be the lineno of the last
child statement recursively.
"""
@@ -1440,8 +1436,7 @@ def is_node_in_type_annotation_context(node: nodes.NodeNG) -> bool:
def is_subclass_of(child: nodes.ClassDef, parent: nodes.ClassDef) -> bool:
- """
- Check if first node is a subclass of second node.
+ """Check if first node is a subclass of second node.
:param child: Node to check for subclass.
:param parent: Node to check for superclass.
:returns: True if child is derived from parent. False otherwise.
@@ -1588,8 +1583,7 @@ def get_iterating_dictionary_name(
def get_subscript_const_value(node: nodes.Subscript) -> nodes.Const:
- """
- Returns the value 'subscript.slice' of a Subscript node.
+ """Returns the value 'subscript.slice' of a Subscript node.
:param node: Subscript Node to extract value from
:returns: Const Node containing subscript value
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index 8bfdc197e..44d54cfd2 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -333,8 +333,7 @@ def _fix_dot_imports(not_consumed):
def _find_frame_imports(name, frame):
- """
- Detect imports in the frame, with the required
+ """Detect imports in the frame, with the required
*name*. Such imports can be considered assignments.
Returns True if an import for the given name was found.
"""
@@ -369,9 +368,7 @@ def _flattened_scope_names(iterator):
def _assigned_locally(name_node):
- """
- Checks if name_node has corresponding assign statement in same scope
- """
+ """Checks if name_node has corresponding assign statement in same scope"""
assign_stmts = name_node.scope().nodes_of_class(nodes.AssignName)
return any(a.name == name_node.name for a in assign_stmts)
@@ -545,9 +542,7 @@ ScopeConsumer = collections.namedtuple(
class NamesConsumer:
- """
- A simple class to handle consumed, to consume and scope type info of node locals
- """
+ """A simple class to handle consumed, to consume and scope type info of node locals"""
def __init__(self, node, scope_type):
self._atomic = ScopeConsumer(
@@ -584,8 +579,7 @@ scope_type : {self._atomic.scope_type}
@property
def consumed_uncertain(self) -> DefaultDict[str, List[nodes.NodeNG]]:
- """
- Retrieves nodes filtered out by get_next_to_consume() that may not
+ """Retrieves nodes filtered out by get_next_to_consume() that may not
have executed, such as statements in except blocks, or statements
in try blocks (when evaluating their corresponding except and finally
blocks). Checkers that want to treat the statements as executed
@@ -598,8 +592,7 @@ scope_type : {self._atomic.scope_type}
return self._atomic.scope_type
def mark_as_consumed(self, name, consumed_nodes):
- """
- Mark the given nodes as consumed for the name.
+ """Mark the given nodes as consumed for the name.
If all of the nodes for the name were consumed, delete the name from
the to_consume dictionary
"""
@@ -612,8 +605,7 @@ scope_type : {self._atomic.scope_type}
del self.to_consume[name]
def get_next_to_consume(self, node):
- """
- Return a list of the nodes that define `node` from this scope. If it is
+ """Return a list of the nodes that define `node` from this scope. If it is
uncertain whether a node will be consumed, such as for statements in
except blocks, add it to self.consumed_uncertain instead of returning it.
Return None to indicate a special case that needs to be handled by the caller.
@@ -700,8 +692,7 @@ scope_type : {self._atomic.scope_type}
@staticmethod
def _uncertain_nodes_in_except_blocks(found_nodes, node, node_statement):
- """
- Return any nodes in ``found_nodes`` that should be treated as uncertain
+ """Return any nodes in ``found_nodes`` that should be treated as uncertain
because they are in an except block.
"""
uncertain_nodes = []
@@ -1846,8 +1837,7 @@ class VariablesChecker(BaseChecker):
return False
def _ignore_class_scope(self, node):
- """
- Return True if the node is in a local class scope, as an assignment.
+ """Return True if the node is in a local class scope, as an assignment.
:param node: Node considered
:type node: astroid.Node
@@ -2169,8 +2159,7 @@ class VariablesChecker(BaseChecker):
def _has_homonym_in_upper_function_scope(
self, node: nodes.Name, index: int
) -> bool:
- """
- Return whether there is a node with the same name in the
+ """Return whether there is a node with the same name in the
to_consume dict of an upper scope and if that scope is a
function
diff --git a/pylint/config/configuration_mixin.py b/pylint/config/configuration_mixin.py
index 2d34933f0..a2abcb752 100644
--- a/pylint/config/configuration_mixin.py
+++ b/pylint/config/configuration_mixin.py
@@ -7,7 +7,8 @@ from pylint.config.options_provider_mixin import OptionsProviderMixIn
class ConfigurationMixIn(OptionsManagerMixIn, OptionsProviderMixIn):
"""Basic mixin for simple configurations which don't need the
- manager / providers model"""
+ manager / providers model
+ """
def __init__(self, *args, **kwargs):
if not args:
diff --git a/pylint/config/option_manager_mixin.py b/pylint/config/option_manager_mixin.py
index e6e031e7d..67740d334 100644
--- a/pylint/config/option_manager_mixin.py
+++ b/pylint/config/option_manager_mixin.py
@@ -332,7 +332,8 @@ class OptionsManagerMixIn:
def load_config_file(self):
"""Dispatch values previously read from a configuration file to each
- option's provider"""
+ option's provider
+ """
parser = self.cfgfile_parser
for section in parser.sections():
for option, value in parser.items(section):
diff --git a/pylint/epylint.py b/pylint/epylint.py
index a7eec3302..5517543a4 100755
--- a/pylint/epylint.py
+++ b/pylint/epylint.py
@@ -69,7 +69,8 @@ from typing import Optional, Sequence
def _get_env():
"""Extracts the environment PYTHONPATH and appends the current 'sys.path'
- to it."""
+ to it.
+ """
env = dict(os.environ)
env["PYTHONPATH"] = os.pathsep.join(sys.path)
return env
diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py
index 611a04aa2..2ff86b00b 100644
--- a/pylint/extensions/_check_docs_utils.py
+++ b/pylint/extensions/_check_docs_utils.py
@@ -121,8 +121,7 @@ def _split_multiple_exc_types(target: str) -> List[str]:
def possible_exc_types(node: nodes.NodeNG) -> Set[nodes.ClassDef]:
- """
- Gets all the possible raised exception types for the given raise node.
+ """Gets all the possible raised exception types for the given raise node.
.. note::
@@ -401,8 +400,7 @@ class SphinxDocstring(Docstring):
class EpytextDocstring(SphinxDocstring):
- """
- Epytext is similar to Sphinx. See the docs:
+ """Epytext is similar to Sphinx. See the docs:
http://epydoc.sourceforge.net/epytext.html
http://epydoc.sourceforge.net/fields.html#fields
diff --git a/pylint/extensions/comparison_placement.py b/pylint/extensions/comparison_placement.py
index c4a5cffcb..e045ebdd0 100644
--- a/pylint/extensions/comparison_placement.py
+++ b/pylint/extensions/comparison_placement.py
@@ -1,8 +1,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-Checks for yoda comparisons (variable before constant)
+"""Checks for yoda comparisons (variable before constant)
See https://en.wikipedia.org/wiki/Yoda_conditions
"""
diff --git a/pylint/extensions/docparams.py b/pylint/extensions/docparams.py
index 8a29a947d..8d9472fbf 100644
--- a/pylint/extensions/docparams.py
+++ b/pylint/extensions/docparams.py
@@ -24,8 +24,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""Pylint plugin for checking in Sphinx, Google, or Numpy style docstrings
-"""
+"""Pylint plugin for checking in Sphinx, Google, or Numpy style docstrings"""
import re
from typing import TYPE_CHECKING, Optional
@@ -642,8 +641,7 @@ class DocstringParameterChecker(BaseChecker):
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.
+ """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)
diff --git a/pylint/extensions/mccabe.py b/pylint/extensions/mccabe.py
index d4e752f48..d675087fe 100644
--- a/pylint/extensions/mccabe.py
+++ b/pylint/extensions/mccabe.py
@@ -181,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"""
+ add message if 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 ef6afefea..9729fd112 100644
--- a/pylint/extensions/overlapping_exceptions.py
+++ b/pylint/extensions/overlapping_exceptions.py
@@ -19,7 +19,8 @@ if TYPE_CHECKING:
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)."""
+ (i.e. overlapping).
+ """
__implements__ = interfaces.IAstroidChecker
diff --git a/pylint/lint/expand_modules.py b/pylint/lint/expand_modules.py
index 7a0dc7004..4d3600a00 100644
--- a/pylint/lint/expand_modules.py
+++ b/pylint/lint/expand_modules.py
@@ -18,7 +18,8 @@ def _modpath_from_file(filename, is_namespace, path=None):
def get_python_path(filepath: str) -> str:
"""TODO This get the python path with the (bad) assumption that there is always
- an __init__.py. This is not true since python 3.3 and is causing problem."""
+ an __init__.py. This is not true since python 3.3 and is causing problem.
+ """
dirname = os.path.realpath(os.path.expanduser(filepath))
if not os.path.isdir(dirname):
dirname = os.path.dirname(dirname)
diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py
index 49ddb29ad..8b1993b4e 100644
--- a/pylint/lint/pylinter.py
+++ b/pylint/lint/pylinter.py
@@ -542,7 +542,8 @@ class PyLinter(
pylintrc=None,
):
"""Some stuff has to be done before ancestors initialization...
- messages store / checkers / reporter / astroid manager"""
+ messages store / checkers / reporter / astroid manager
+ """
# Attributes for reporters
self.reporter: Union[reporters.BaseReporter, reporters.MultiReporter]
if reporter:
@@ -851,7 +852,8 @@ class PyLinter(
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
@@ -1464,7 +1466,8 @@ class PyLinter(
end_col_offset: Optional[int],
) -> None:
"""After various checks have passed a single Message is
- passed to the reporter and added to stats"""
+ passed to the reporter and added to stats
+ """
message_definition.check_message_definition(line, node)
# Look up "location" data of node if not yet supplied
@@ -1698,7 +1701,8 @@ class PyLinter(
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."""
+ it could 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_id_store.py b/pylint/message/message_id_store.py
index a16d12bfe..c4d1f4e8f 100644
--- a/pylint/message/message_id_store.py
+++ b/pylint/message/message_id_store.py
@@ -52,7 +52,8 @@ class MessageIdStore:
"""Add valid message id.
There is a little duplication with add_legacy_msgid_and_symbol to avoid a function call,
- this is called a lot at initialization."""
+ this is called a lot at initialization.
+ """
self.__msgid_to_symbol[msgid] = symbol
self.__symbol_to_msgid[symbol] = msgid
@@ -62,7 +63,8 @@ class MessageIdStore:
"""Add valid legacy message id.
There is a little duplication with add_msgid_and_symbol to avoid a function call,
- this is called a lot at initialization."""
+ this is called a lot at initialization.
+ """
self.__msgid_to_symbol[msgid] = symbol
self.__symbol_to_msgid[symbol] = msgid
existing_old_names = self.__old_names.get(msgid, [])
diff --git a/pylint/pyreverse/__init__.py b/pylint/pyreverse/__init__.py
index fdbbe1e83..390244522 100644
--- a/pylint/pyreverse/__init__.py
+++ b/pylint/pyreverse/__init__.py
@@ -1,8 +1,6 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-pyreverse.extensions
-"""
+"""pyreverse.extensions"""
__revision__ = "$Id $"
diff --git a/pylint/pyreverse/diadefslib.py b/pylint/pyreverse/diadefslib.py
index aee686da5..1e059dea3 100644
--- a/pylint/pyreverse/diadefslib.py
+++ b/pylint/pyreverse/diadefslib.py
@@ -19,8 +19,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""handle diagram generation options for class diagram or default diagrams
-"""
+"""handle diagram generation options for class diagram or default diagrams"""
from typing import Any, Optional
diff --git a/pylint/pyreverse/dot_printer.py b/pylint/pyreverse/dot_printer.py
index c2fd62fb9..fb7f3d8bc 100644
--- a/pylint/pyreverse/dot_printer.py
+++ b/pylint/pyreverse/dot_printer.py
@@ -8,9 +8,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-Class to generate files in dot format and image formats supported by Graphviz.
-"""
+"""Class to generate files in dot format and image formats supported by Graphviz."""
import os
import subprocess
import sys
diff --git a/pylint/pyreverse/inspector.py b/pylint/pyreverse/inspector.py
index 25819f5aa..2c7162d7c 100644
--- a/pylint/pyreverse/inspector.py
+++ b/pylint/pyreverse/inspector.py
@@ -14,8 +14,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-Visitor doing some postprocessing on the astroid tree.
+"""Visitor doing some postprocessing on the astroid tree.
Try to resolve definitions (namespace) dictionary, relationship...
"""
import collections
diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py
index c48b9f3c3..f96c07a59 100644
--- a/pylint/pyreverse/main.py
+++ b/pylint/pyreverse/main.py
@@ -20,8 +20,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
- %prog [options] <packages>
+"""%prog [options] <packages>
create UML diagrams for classes and modules in <packages>
"""
diff --git a/pylint/pyreverse/mermaidjs_printer.py b/pylint/pyreverse/mermaidjs_printer.py
index d215b559d..bf12fa2ec 100644
--- a/pylint/pyreverse/mermaidjs_printer.py
+++ b/pylint/pyreverse/mermaidjs_printer.py
@@ -3,9 +3,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-Class to generate files in mermaidjs format
-"""
+"""Class to generate files in mermaidjs format"""
from typing import Dict, Optional
from pylint.pyreverse.printer import EdgeType, NodeProperties, NodeType, Printer
diff --git a/pylint/pyreverse/plantuml_printer.py b/pylint/pyreverse/plantuml_printer.py
index c73cddd5e..be49c51eb 100644
--- a/pylint/pyreverse/plantuml_printer.py
+++ b/pylint/pyreverse/plantuml_printer.py
@@ -3,9 +3,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-Class to generate files in dot format and image formats supported by Graphviz.
-"""
+"""Class to generate files in dot format and image formats supported by Graphviz."""
from typing import Dict, Optional
from pylint.pyreverse.printer import EdgeType, Layout, NodeProperties, NodeType, Printer
diff --git a/pylint/pyreverse/printer.py b/pylint/pyreverse/printer.py
index 0a8715011..0fdee79fd 100644
--- a/pylint/pyreverse/printer.py
+++ b/pylint/pyreverse/printer.py
@@ -7,9 +7,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-Base class defining the interface for a printer.
-"""
+"""Base class defining the interface for a printer."""
from abc import ABC, abstractmethod
from enum import Enum
from typing import List, NamedTuple, Optional
diff --git a/pylint/pyreverse/utils.py b/pylint/pyreverse/utils.py
index e22061781..454b9dfc9 100644
--- a/pylint/pyreverse/utils.py
+++ b/pylint/pyreverse/utils.py
@@ -270,7 +270,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"""
+ otherwise return a set of the inferred types using the NodeNG.infer method
+ """
ann = get_annotation(node)
try:
@@ -286,7 +287,8 @@ def infer_node(node: Union[nodes.AssignAttr, nodes.AssignName]) -> set:
def check_graphviz_availability():
"""Check if the ``dot`` command is available on the machine.
This is needed if image output is desired and ``dot`` is used to convert
- from *.dot or *.gv into the final output format."""
+ from *.dot or *.gv into the final output format.
+ """
if shutil.which("dot") is None:
print(
"The requested output format is currently not available.\n"
diff --git a/pylint/reporters/multi_reporter.py b/pylint/reporters/multi_reporter.py
index 3eb75181e..61740908d 100644
--- a/pylint/reporters/multi_reporter.py
+++ b/pylint/reporters/multi_reporter.py
@@ -49,8 +49,7 @@ class MultiReporter:
@out.setter
def out(self, output: Optional[AnyFile] = None):
- """
- MultiReporter doesn't have its own output. This method is only
+ """MultiReporter doesn't have its own output. This method is only
provided for API parity with BaseReporter and should not be called
with non-None values for 'output'.
"""
diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py
index b69a3a139..b0db63f11 100644
--- a/pylint/reporters/text.py
+++ b/pylint/reporters/text.py
@@ -60,8 +60,7 @@ class MessageStyle(NamedTuple):
or the color number when 256 colors are available
"""
style: Tuple[str, ...] = ()
- """Tuple of style strings (see `ANSI_COLORS` for available values).
- """
+ """Tuple of style strings (see `ANSI_COLORS` for available values)."""
ColorMappingDict = Dict[str, MessageStyle]
diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py
index 8dbf5e60b..9bbf00d2f 100644
--- a/pylint/testutils/lint_module_test.py
+++ b/pylint/testutils/lint_module_test.py
@@ -142,7 +142,8 @@ class LintModuleTest:
) -> Tuple[MessageCounter, Dict[Tuple[int, str], int]]:
"""Takes two multisets and compares them.
- A multiset is a dict with the cardinality of the key as the value."""
+ A multiset is a dict with the cardinality of the key as the value.
+ """
missing = expected_entries.copy()
missing.subtract(actual_entries)
unexpected = {}
diff --git a/pylint/testutils/output_line.py b/pylint/testutils/output_line.py
index 9c0c76239..fe8024795 100644
--- a/pylint/testutils/output_line.py
+++ b/pylint/testutils/output_line.py
@@ -104,7 +104,8 @@ class OutputLine(NamedTuple):
@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`."""
+ `min_pyver_end_position`.
+ """
if not check_endline:
return None # pragma: no cover
return value
diff --git a/pylint/testutils/pyreverse.py b/pylint/testutils/pyreverse.py
index f70fe540f..ac72def41 100644
--- a/pylint/testutils/pyreverse.py
+++ b/pylint/testutils/pyreverse.py
@@ -8,7 +8,8 @@ from typing import List, Optional, Tuple
# A NamedTuple is not possible as some tests need to modify attributes during the test.
class PyreverseConfig: # pylint: disable=too-many-instance-attributes, too-many-arguments
"""Holds the configuration options for Pyreverse.
- The default values correspond to the defaults of the options' parser."""
+ The default values correspond to the defaults of the options' parser.
+ """
def __init__(
self,
diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py
index 1cd1213a7..df506465d 100644
--- a/pylint/utils/pragma_parser.py
+++ b/pylint/utils/pragma_parser.py
@@ -61,13 +61,10 @@ def emit_pragma_representer(action: str, messages: List[str]) -> PragmaRepresent
class PragmaParserError(Exception):
- """
- A class for exceptions thrown by pragma_parser module
- """
+ """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
@@ -76,15 +73,11 @@ class PragmaParserError(Exception):
class UnRecognizedOptionError(PragmaParserError):
- """
- Thrown in case the of a valid but unrecognized option
- """
+ """Thrown in case the of a valid but unrecognized option"""
class InvalidPragmaError(PragmaParserError):
- """
- Thrown in case the pragma is invalid
- """
+ """Thrown in case the pragma is invalid"""
def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]:
diff --git a/script/bump_changelog.py b/script/bump_changelog.py
index 6b8e4abbf..6e25719d4 100644
--- a/script/bump_changelog.py
+++ b/script/bump_changelog.py
@@ -1,9 +1,7 @@
# ORIGINAL here: https://github.com/PyCQA/astroid/blob/main/script/bump_changelog.py
# DO NOT MODIFY DIRECTLY
-"""
-This script permits to upgrade the changelog in astroid or pylint when releasing a version.
-"""
+"""This script permits to upgrade the changelog in astroid or pylint when releasing a version."""
# pylint: disable=logging-fstring-interpolation
import argparse
import enum
diff --git a/tests/benchmark/test_baseline_benchmarks.py b/tests/benchmark/test_baseline_benchmarks.py
index 58939fd4d..5227ca5ae 100644
--- a/tests/benchmark/test_baseline_benchmarks.py
+++ b/tests/benchmark/test_baseline_benchmarks.py
@@ -40,7 +40,8 @@ class SleepingChecker(BaseChecker):
"""A checker that sleeps, the wall-clock time should reduce as we add workers
As we apply a roughly constant amount of "work" in this checker any variance is
- likely to be caused by the pylint system."""
+ likely to be caused by the pylint system.
+ """
__implements__ = (pylint.interfaces.IRawChecker,)
@@ -57,7 +58,8 @@ class SleepingChecker(BaseChecker):
def process_module(self, _node: nodes.Module) -> None:
"""Sleeps for `sleep_duration` on each call
- This effectively means each file costs ~`sleep_duration`+framework overhead"""
+ This effectively means each file costs ~`sleep_duration`+framework overhead
+ """
time.sleep(self.sleep_duration)
@@ -65,7 +67,8 @@ class SleepingCheckerLong(BaseChecker):
"""A checker that sleeps, the wall-clock time should reduce as we add workers
As we apply a roughly constant amount of "work" in this checker any variance is
- likely to be caused by the pylint system."""
+ likely to be caused by the pylint system.
+ """
__implements__ = (pylint.interfaces.IRawChecker,)
@@ -82,7 +85,8 @@ class SleepingCheckerLong(BaseChecker):
def process_module(self, _node: nodes.Module) -> None:
"""Sleeps for `sleep_duration` on each call
- This effectively means each file costs ~`sleep_duration`+framework overhead"""
+ This effectively means each file costs ~`sleep_duration`+framework overhead
+ """
time.sleep(self.sleep_duration)
@@ -111,7 +115,8 @@ class TestEstablishBaselineBenchmarks:
"""Naive benchmarks for the high-level pylint framework
Because this benchmarks the fundamental and common parts and changes seen here will
- impact everything else"""
+ impact everything else
+ """
empty_filepath = _empty_filepath()
empty_file_info = FileItem(
@@ -176,7 +181,8 @@ class TestEstablishBaselineBenchmarks:
"""Establish a baseline with only 'master' checker being run in -j1
We do not register any checkers except the default 'master', so the cost is just
- that of the system with a lot of files registered"""
+ that of the system with a lot of files registered
+ """
if benchmark.disabled:
benchmark(print, "skipping, only benchmark large file counts")
return # _only_ run this test is profiling
@@ -195,7 +201,8 @@ class TestEstablishBaselineBenchmarks:
As with the -j1 variant above `test_baseline_lots_of_files_j1`, we do not
register any checkers except the default 'master', so the cost is just that of
- the check_parallel system across 10 workers, plus the overhead of PyLinter"""
+ the check_parallel system across 10 workers, plus the overhead of PyLinter
+ """
if benchmark.disabled:
benchmark(print, "skipping, only benchmark large file counts")
return # _only_ run this test is profiling
@@ -213,7 +220,8 @@ class TestEstablishBaselineBenchmarks:
"""Baselines pylint for a single extra checker being run in -j1, for N-files
We use a checker that does no work, so the cost is just that of the system at
- scale"""
+ scale
+ """
if benchmark.disabled:
benchmark(print, "skipping, only benchmark large file counts")
return # _only_ run this test is profiling
@@ -232,7 +240,8 @@ class TestEstablishBaselineBenchmarks:
"""Baselines pylint for a single extra checker being run in -j10, for N-files
We use a checker that does no work, so the cost is just that of the system at
- scale, across workers"""
+ scale, across workers
+ """
if benchmark.disabled:
benchmark(print, "skipping, only benchmark large file counts")
return # _only_ run this test is profiling
@@ -254,7 +263,8 @@ class TestEstablishBaselineBenchmarks:
impact of running a simple system with -j1 against the same system with -j10.
We expect this benchmark to take very close to
- `numfiles*SleepingChecker.sleep_duration`"""
+ `numfiles*SleepingChecker.sleep_duration`
+ """
if benchmark.disabled:
benchmark(print, "skipping, do not want to sleep in main tests")
return # _only_ run this test is profiling
@@ -279,7 +289,8 @@ class TestEstablishBaselineBenchmarks:
`error_margin*(1/J)*(numfiles*SleepingChecker.sleep_duration)`
Because of the cost of the framework and system the performance difference will
- *not* be 1/10 of -j1 versions."""
+ *not* be 1/10 of -j1 versions.
+ """
if benchmark.disabled:
benchmark(print, "skipping, do not want to sleep in main tests")
return # _only_ run this test is profiling
diff --git a/tests/checkers/unittest_design.py b/tests/checkers/unittest_design.py
index fd9c78f0e..faf8f6e9e 100644
--- a/tests/checkers/unittest_design.py
+++ b/tests/checkers/unittest_design.py
@@ -56,7 +56,8 @@ class TestDesignChecker(CheckerTestCase):
def test_ignore_paths_with_no_value(self) -> None:
"""Test exclude-too-few-public-methods option with no value.
- Compare against actual list to see if validator works."""
+ Compare against actual list to see if validator works.
+ """
options = get_global_option(self.checker, "exclude-too-few-public-methods")
assert options == []
diff --git a/tests/checkers/unittest_format.py b/tests/checkers/unittest_format.py
index 1fdb0f8bc..8aa7ec0c7 100644
--- a/tests/checkers/unittest_format.py
+++ b/tests/checkers/unittest_format.py
@@ -109,7 +109,8 @@ class TestSuperfluousParentheses(CheckerTestCase):
def testNoSuperfluousParensWalrusOperatorIf(self) -> None:
"""Parenthesis change the meaning of assignment in the walrus operator
- and so are not always superfluous:"""
+ and so are not always superfluous:
+ """
cases = [
("if (odd := is_odd(i))\n"),
("not (foo := 5)\n"),
@@ -177,8 +178,7 @@ class TestCheckSpace(CheckerTestCase):
def test_disable_global_option_end_of_line() -> None:
- """
- Test for issue with disabling tokenizer messages
+ """Test for issue with disabling tokenizer messages
that extend beyond the scope of the ast tokens
"""
file_ = tempfile.NamedTemporaryFile("w", delete=False)
diff --git a/tests/checkers/unittest_stdlib.py b/tests/checkers/unittest_stdlib.py
index 9529af3ad..88f5c7922 100644
--- a/tests/checkers/unittest_stdlib.py
+++ b/tests/checkers/unittest_stdlib.py
@@ -45,7 +45,8 @@ class TestStdlibChecker(CheckerTestCase):
While this test might seem weird since it uses a transform, it's actually testing a crash
that happened in production, but there was no way to retrieve the code for which this
- occurred (how an AssignAttr got to be the result of a function inference beats me...)"""
+ occurred (how an AssignAttr got to be the result of a function inference beats me...)
+ """
def infer_func(
node: Name, context: Optional[Any] = None
diff --git a/tests/checkers/unittest_variables.py b/tests/checkers/unittest_variables.py
index a59278bb9..f42c3fbae 100644
--- a/tests/checkers/unittest_variables.py
+++ b/tests/checkers/unittest_variables.py
@@ -198,7 +198,8 @@ class TestVariablesCheckerWithTearDown(CheckerTestCase):
@set_config(ignored_argument_names=re.compile("arg"))
def test_ignored_argument_names_no_message(self) -> None:
"""Make sure is_ignored_argument_names properly ignores
- function arguments"""
+ function arguments
+ """
node = astroid.parse(
"""
def fooby(arg):
diff --git a/tests/config/test_functional_config_loading.py b/tests/config/test_functional_config_loading.py
index 0dacb6973..1937435f7 100644
--- a/tests/config/test_functional_config_loading.py
+++ b/tests/config/test_functional_config_loading.py
@@ -1,8 +1,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-This launches the configuration functional tests. This permits to test configuration
+"""This launches the configuration functional tests. This permits to test configuration
files by providing a file with the appropriate extension in the ``tests/config/functional``
directory.
diff --git a/tests/config/unittest_config.py b/tests/config/unittest_config.py
index d98b2a7a1..72474abe3 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."""
+ for options declared in PyLinter.
+ """
class Checker(BaseChecker):
name = "checker"
@@ -98,7 +99,8 @@ class TestPyLinterOptionSetters(CheckerTestCase):
def test_ignore_paths_with_no_value(self) -> None:
"""Test ignore-paths option with no value.
- Compare against actual list to see if validator works."""
+ Compare against actual list to see if validator works.
+ """
options = get_global_option(self.checker, "ignore-paths")
assert options == []
diff --git a/tests/pyreverse/test_diadefs.py b/tests/pyreverse/test_diadefs.py
index b17279280..5fe73bf36 100644
--- a/tests/pyreverse/test_diadefs.py
+++ b/tests/pyreverse/test_diadefs.py
@@ -128,7 +128,8 @@ class TestDefaultDiadefGenerator:
self, default_config: PyreverseConfig, get_project: Callable
) -> None:
"""functional test of relations extraction;
- different classes possibly in different modules"""
+ different classes possibly in 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_inspector.py b/tests/pyreverse/test_inspector.py
index dec38f541..6fff4e5fc 100644
--- a/tests/pyreverse/test_inspector.py
+++ b/tests/pyreverse/test_inspector.py
@@ -13,9 +13,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
- for the visitors.diadefs module
-"""
+"""for the visitors.diadefs module"""
# pylint: disable=redefined-outer-name
import os
diff --git a/tests/pyreverse/test_printer_factory.py b/tests/pyreverse/test_printer_factory.py
index f2ad7106a..f39b90dad 100644
--- a/tests/pyreverse/test_printer_factory.py
+++ b/tests/pyreverse/test_printer_factory.py
@@ -3,9 +3,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-Unit tests for pylint.pyreverse.printer_factory
-"""
+"""Unit tests for pylint.pyreverse.printer_factory"""
import pytest
diff --git a/tests/pyreverse/test_utils.py b/tests/pyreverse/test_utils.py
index c631917d9..94ee858e0 100644
--- a/tests/pyreverse/test_utils.py
+++ b/tests/pyreverse/test_utils.py
@@ -109,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"""
+ has a type annotation
+ """
node = astroid.extract_node(
"""
class Component:
diff --git a/tests/pyreverse/test_writer.py b/tests/pyreverse/test_writer.py
index b436b65e9..426cef68e 100644
--- a/tests/pyreverse/test_writer.py
+++ b/tests/pyreverse/test_writer.py
@@ -17,9 +17,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""
-Unit test for ``DiagramWriter``
-"""
+"""Unit test for ``DiagramWriter``"""
import codecs
diff --git a/tests/test_check_parallel.py b/tests/test_check_parallel.py
index bc27530f3..738b3061c 100644
--- a/tests/test_check_parallel.py
+++ b/tests/test_check_parallel.py
@@ -359,7 +359,8 @@ class TestCheckParallel:
def test_invoke_single_job(self) -> None:
"""Tests basic checkers functionality using just a single workderdo
- This is *not* the same -j1 and does not happen under normal operation"""
+ This is *not* the same -j1 and does not happen under normal operation
+ """
linter = PyLinter(reporter=Reporter())
linter.register_checker(SequentialTestChecker(linter))
@@ -429,7 +430,8 @@ class TestCheckParallel:
number of checkers applied.
This test becomes more important if we want to change how we parametrise the
- checkers, for example if we aim to batch the files across jobs."""
+ checkers, for example if we aim to batch the files across jobs.
+ """
# define the stats we expect to get back from the runs, these should only vary
# with the number of files.
diff --git a/tests/test_func.py b/tests/test_func.py
index 575773bb9..3e6bf36ce 100644
--- a/tests/test_func.py
+++ b/tests/test_func.py
@@ -39,7 +39,8 @@ INFO_TEST_RGX = re.compile(r"^func_i\d\d\d\d$")
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"""
+ This function is not typed because it is legacy code
+ """
return f"in {ex.file}\n:: {', '.join(ex.args)}"
diff --git a/tests/test_self.py b/tests/test_self.py
index 9f33d745c..99bf56280 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -183,8 +183,7 @@ class TestRunTC:
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
+ """Run Pylint with the ``output`` option set (must be included in
the ``args`` passed to this method!) and check the file content afterwards.
"""
out = StringIO()
@@ -1164,9 +1163,7 @@ class TestRunTC:
self._runtest([path, "--fail-under=-10"] + args, code=expected)
def test_one_module_fatal_error(self):
- """
- Fatal errors in one of several modules linted still exits non-zero.
- """
+ """Fatal errors in one of several modules linted still exits non-zero."""
valid_path = join(HERE, "conftest.py")
invalid_path = join(HERE, "garbagePath.py")
self._runtest([valid_path, invalid_path], code=1)
diff --git a/tests/unittest_reporting.py b/tests/unittest_reporting.py
index 29aac8640..1ee947759 100644
--- a/tests/unittest_reporting.py
+++ b/tests/unittest_reporting.py
@@ -94,7 +94,8 @@ def test_template_option_end_line(linter) -> None:
def test_template_option_non_existing(linter) -> None:
"""Test the msg-template option with non-existent options.
This makes sure that this option remains backwards compatible as new
- parameters do not break on previous versions"""
+ parameters do not break on previous versions
+ """
output = StringIO()
linter.reporter.out = output
linter.set_option(