Skip to content

Commit 708fbaf

Browse files
Apply pydocstring formatter
1 parent efd08b5 commit 708fbaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+221
-124
lines changed

.pre-commit-config.yaml

-12
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ repos:
3636
- id: black
3737
args: [--safe, --quiet]
3838
exclude: *fixtures
39-
- repo: https://github.com/Pierre-Sassoulas/docformatter
40-
rev: master
41-
hooks:
42-
- id: docformatter
43-
# black want 88 char per line max, +3 quotes for docstring summaries
44-
args:
45-
[
46-
"--in-place",
47-
"--wrap-summaries=88",
48-
"--wrap-descriptions=88",
49-
]
50-
exclude: *fixtures
5139
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker/
5240
rev: 1.0.1
5341
hooks:

examples/custom_raw.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
class MyRawChecker(BaseChecker):
1313
"""Check for line continuations with '\' instead of using triple quoted string or
14-
parenthesis."""
14+
parenthesis.
15+
"""
1516

1617
__implements__ = IRawChecker
1718

pylint/checkers/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def table_lines_from_stats(
6666
stat_type: Literal["duplicated_lines", "message_types"],
6767
) -> List[str]:
6868
"""Get values listed in <columns> from <stats> and <old_stats>, and return a
69-
formatted list of values, designed to be given to a ureport.Table object."""
69+
formatted list of values, designed to be given to a ureport.Table object.
70+
"""
7071
lines: List[str] = []
7172
if stat_type == "duplicated_lines":
7273
new: List[Tuple[str, Union[str, int, float]]] = [

pylint/checkers/base.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
class NamingStyle:
104104
"""It may seem counterintuitive that single naming style has multiple "accepted"
105105
forms of regular expressions, but we need to special-case stuff like dunder names in
106-
method names."""
106+
method names.
107+
"""
107108

108109
ANY: Pattern[str] = re.compile(".*")
109110
CLASS_NAME_RGX: Pattern[str] = ANY
@@ -1300,7 +1301,8 @@ def visit_lambda(self, node: nodes.Lambda) -> None:
13001301
@utils.check_messages("dangerous-default-value")
13011302
def visit_functiondef(self, node: nodes.FunctionDef) -> None:
13021303
"""Check function name, docstring, args, redefinition, variable names,
1303-
locals."""
1304+
locals.
1305+
"""
13041306
if node.is_method():
13051307
self.linter.stats.node_count["method"] += 1
13061308
else:
@@ -1363,7 +1365,8 @@ def visit_return(self, node: nodes.Return) -> None:
13631365
@utils.check_messages("unreachable")
13641366
def visit_continue(self, node: nodes.Continue) -> None:
13651367
"""Check is the node has a right sibling (if so, that's some unreachable
1366-
code)"""
1368+
code)
1369+
"""
13671370
self._check_unreachable(node)
13681371

13691372
@utils.check_messages("unreachable", "lost-exception")
@@ -1381,7 +1384,8 @@ def visit_break(self, node: nodes.Break) -> None:
13811384
@utils.check_messages("unreachable")
13821385
def visit_raise(self, node: nodes.Raise) -> None:
13831386
"""Check if the node has a right sibling (if so, that's some unreachable
1384-
code)"""
1387+
code)
1388+
"""
13851389
self._check_unreachable(node)
13861390

13871391
def _check_misplaced_format_function(self, call_node):

pylint/checkers/classes/class_checker.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,8 @@ def _check_proper_bases(self, node):
840840

841841
def _check_typing_final(self, node: nodes.ClassDef) -> None:
842842
"""Detect that a class does not subclass a class decorated with
843-
`typing.final`"""
843+
`typing.final`
844+
"""
844845
if not self._py38_plus:
845846
return
846847
for base in node.bases:
@@ -1872,7 +1873,8 @@ def is_abstract(method):
18721873

18731874
def _check_init(self, node):
18741875
"""Check that the __init__ method call super or ancestors'__init__ method
1875-
(unless it is used for type hinting with `typing.overload`)"""
1876+
(unless it is used for type hinting with `typing.overload`)
1877+
"""
18761878
if not self.linter.is_message_enabled(
18771879
"super-init-not-called"
18781880
) and not self.linter.is_message_enabled("non-parent-init-called"):
@@ -2027,7 +2029,8 @@ def _is_mandatory_method_param(self, node):
20272029

20282030
def _ancestors_to_call(klass_node, method="__init__"):
20292031
"""Return a dictionary where keys are the list of base classes providing the queried
2030-
method, and so that should/may be called from the method node."""
2032+
method, and so that should/may be called from the method node.
2033+
"""
20312034
to_call = {}
20322035
for base_node in klass_node.ancestors(recurs=False):
20332036
try:

pylint/checkers/design_analysis.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ def leave_classdef(self, node: nodes.ClassDef) -> None:
528528
)
529529
def visit_functiondef(self, node: nodes.FunctionDef) -> None:
530530
"""Check function name, docstring, arguments, redefinition, variable names, max
531-
locals."""
531+
locals.
532+
"""
532533
# init branch and returns counters
533534
self._returns.append(0)
534535
# check number of arguments
@@ -637,7 +638,8 @@ def visit_if(self, node: nodes.If) -> None:
637638

638639
def _check_boolean_expressions(self, node):
639640
"""Go through "if" node `node` and count its boolean expressions if the 'if'
640-
node test is a BoolOp node."""
641+
node test is a BoolOp node.
642+
"""
641643
condition = node.test
642644
if not isinstance(condition, astroid.BoolOp):
643645
return

pylint/checkers/format.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,8 @@ def is_line_length_check_activated(pylint_pattern_match_object) -> bool:
716716
@staticmethod
717717
def specific_splitlines(lines: str) -> List[str]:
718718
"""Split lines according to universal newlines except those in a specific
719-
sets."""
719+
sets.
720+
"""
720721
unsplit_ends = {
721722
"\v",
722723
"\x0b",

pylint/checkers/imports.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def _ignore_import_failure(node, modname, ignored_modules):
139139

140140
def _make_tree_defs(mod_files_list):
141141
"""Get a list of 2-uple (module, list_of_files_which_import_this_module), it will
142-
return a dictionary to represent this as a tree."""
142+
return a dictionary to represent this as a tree.
143+
"""
143144
tree_defs = {}
144145
for mod, files in mod_files_list:
145146
node = (tree_defs, ())
@@ -192,7 +193,8 @@ def _make_graph(
192193
filename: str, dep_info: Dict[str, Set[str]], sect: Section, gtype: str
193194
):
194195
"""Generate a dependencies graph and add some information about it in the report's
195-
section."""
196+
section.
197+
"""
196198
outputfile = _dependencies_graph(filename, dep_info)
197199
sect.append(Paragraph((f"{gtype}imports graph has been written to {outputfile}",)))
198200

pylint/checkers/refactoring/implicit_booleaness_checker.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ def instance_has_bool(class_def: nodes.ClassDef) -> bool:
128128
@utils.check_messages("use-implicit-booleaness-not-len")
129129
def visit_unaryop(self, node: nodes.UnaryOp) -> None:
130130
"""`not len(S)` must become `not S` regardless if the parent block is a test
131-
condition or something else (boolean expression) e.g. `if not len(S):`"""
131+
condition or something else (boolean expression) e.g. `if not len(S):`
132+
"""
132133
if (
133134
isinstance(node, nodes.UnaryOp)
134135
and node.op == "not"
@@ -209,7 +210,8 @@ def _check_use_implicit_booleaness_not_comparison(
209210
@staticmethod
210211
def base_classes_of_node(instance: nodes.ClassDef) -> List[str]:
211212
"""Return all the classes names that a ClassDef inherit from including
212-
'object'."""
213+
'object'.
214+
"""
213215
try:
214216
return [instance.name] + [x.name for x in instance.ancestors()]
215217
except TypeError:

pylint/checkers/refactoring/recommendation_checker.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None:
103103

104104
def _check_use_maxsplit_arg(self, node: nodes.Call) -> None:
105105
"""Add message when accessing first or last elements of a str.split() or
106-
str.rsplit()."""
106+
str.rsplit().
107+
"""
107108

108109
# Check if call is split() or rsplit()
109110
if not (
@@ -338,7 +339,8 @@ def visit_const(self, node: nodes.Const) -> None:
338339

339340
def _detect_replacable_format_call(self, node: nodes.Const) -> None:
340341
"""Check whether a string is used in a call to format() or '%' and whether it
341-
can be replaced by an f-string."""
342+
can be replaced by an f-string.
343+
"""
342344
if (
343345
isinstance(node.parent, nodes.Attribute)
344346
and node.parent.attrname == "format"

pylint/checkers/refactoring/refactoring_checker.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def _is_a_return_statement(node: nodes.Call) -> bool:
119119

120120
def _is_part_of_with_items(node: nodes.Call) -> bool:
121121
"""Checks if one of the node's parents is a ``nodes.With`` node and that the node
122-
itself is located somewhere under its ``items``."""
122+
itself is located somewhere under its ``items``.
123+
"""
123124
frame = node.frame()
124125
current = node
125126
while current != frame:
@@ -133,7 +134,8 @@ def _is_part_of_with_items(node: nodes.Call) -> bool:
133134

134135
def _will_be_released_automatically(node: nodes.Call) -> bool:
135136
"""Checks if a call that could be used in a ``with`` statement is used in an
136-
alternative construct which would ensure that its __exit__ method is called."""
137+
alternative construct which would ensure that its __exit__ method is called.
138+
"""
137139
callables_taking_care_of_exit = frozenset(
138140
(
139141
"contextlib._BaseExitStack.enter_context",
@@ -150,7 +152,8 @@ def _will_be_released_automatically(node: nodes.Call) -> bool:
150152

151153
class ConsiderUsingWithStack(NamedTuple):
152154
"""Stack for objects that may potentially trigger a R1732 message if they are not
153-
used in a ``with`` block later on."""
155+
used in a ``with`` block later on.
156+
"""
154157

155158
module_scope: Dict[str, nodes.NodeNG] = {}
156159
class_scope: Dict[str, nodes.NodeNG] = {}

pylint/checkers/similar.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ class LineSpecifs(NamedTuple):
113113
class CplSuccessiveLinesLimits:
114114
"""This class holds a couple of SuccessiveLinesLimits objects, one for each file
115115
compared, and a counter on the number of common lines between both stripped lines
116-
collections extracted from both files."""
116+
collections extracted from both files.
117+
"""
117118

118119
__slots__ = ("first_file", "second_file", "effective_cmn_lines_nb")
119120

@@ -135,7 +136,8 @@ def __init__(
135136

136137
class LinesChunk:
137138
"""The LinesChunk object computes and stores the hash of some consecutive stripped
138-
lines of a lineset."""
139+
lines of a lineset.
140+
"""
139141

140142
__slots__ = ("_fileid", "_index", "_hash")
141143

@@ -597,7 +599,8 @@ def _get_functions(
597599
functions: List[nodes.NodeNG], tree: nodes.NodeNG
598600
) -> List[nodes.NodeNG]:
599601
"""Recursively get all functions including nested in the classes from the
600-
tree."""
602+
tree.
603+
"""
601604

602605
for node in tree.body:
603606
if isinstance(node, (nodes.FunctionDef, nodes.AsyncFunctionDef)):

pylint/checkers/spelling.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ class SphinxDirectives(RegExFilter):
146146

147147
class ForwardSlashChunker(Chunker):
148148
"""This chunker allows splitting words like 'before/after' into 'before' and
149-
'after'."""
149+
'after'.
150+
"""
150151

151152
def next(self):
152153
while True:

pylint/checkers/strings.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@
227227

228228
def get_access_path(key, parts):
229229
"""Given a list of format specifiers, returns the final access path (e.g.
230-
a.b.c[0][1])."""
230+
a.b.c[0][1]).
231+
"""
231232
path = []
232233
for is_attribute, specifier in parts:
233234
if is_attribute:
@@ -256,7 +257,8 @@ def arg_matches_format_type(arg_type, format_type):
256257

257258
class StringFormatChecker(BaseChecker):
258259
"""Checks string formatting operations to ensure that the format string is valid and
259-
the arguments match the format string."""
260+
the arguments match the format string.
261+
"""
260262

261263
__implements__ = (IAstroidChecker,)
262264
name = "string"
@@ -538,7 +540,8 @@ def _check_new_format(self, node, func):
538540

539541
def _check_new_format_specifiers(self, node, fields, named):
540542
"""Check attribute and index access in the format string ("{0.a}" and
541-
"{0[a]}")."""
543+
"{0[a]}").
544+
"""
542545
for key, specifiers in fields:
543546
# Obtain the argument. If it can't be obtained
544547
# or inferred, skip this check.

pylint/checkers/typecheck.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,8 @@ def visit_assign(self, node: nodes.Assign) -> None:
11411141

11421142
def _check_assignment_from_function_call(self, node):
11431143
"""Check that if assigning to a function call, the function is possibly
1144-
returning something valuable."""
1144+
returning something valuable.
1145+
"""
11451146
if not isinstance(node.value, nodes.Call):
11461147
return
11471148

@@ -1209,7 +1210,8 @@ def _check_dundername_is_string(self, node):
12091210

12101211
def _check_uninferable_call(self, node):
12111212
"""Check that the given uninferable Call node does not call an actual
1212-
function."""
1213+
function.
1214+
"""
12131215
if not isinstance(node.func, nodes.Attribute):
12141216
return
12151217

@@ -1310,7 +1312,8 @@ def _check_isinstance_args(self, node):
13101312
def visit_call(self, node: nodes.Call) -> None:
13111313
"""Check that called functions/methods are inferred to callable objects, and
13121314
that the arguments passed to the function match the parameters in the inferred
1313-
function's definition."""
1315+
function's definition.
1316+
"""
13141317
called = safe_infer(node.func)
13151318

13161319
self._check_not_callable(node, called)
@@ -1508,7 +1511,8 @@ def _keyword_argument_is_in_all_decorator_returns(
15081511
func: nodes.FunctionDef, keyword: str
15091512
) -> bool:
15101513
"""Check if the keyword argument exists in all signatures of the return values
1511-
of all decorators of the function."""
1514+
of all decorators of the function.
1515+
"""
15121516
if not func.decorators:
15131517
return False
15141518

pylint/checkers/unsupported_version.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
class UnsupportedVersionChecker(BaseChecker):
3030
"""Checker for features that are not supported by all python versions indicated by
31-
the py-version setting."""
31+
the py-version setting.
32+
"""
3233

3334
__implements__ = (IAstroidChecker,)
3435
name = "unsupported_version"
@@ -66,7 +67,8 @@ def visit_decorators(self, node: nodes.Decorators) -> None:
6667

6768
def _check_typing_final(self, node: nodes.Decorators) -> None:
6869
"""Add a message when the `typing.final` decorator is used and the py- version
69-
is lower than 3.8."""
70+
is lower than 3.8.
71+
"""
7072
if self._py38_plus:
7173
return
7274

0 commit comments

Comments
 (0)