Skip to content

Commit e8aeaf3

Browse files
More automated (curated) docformatter formatting
1 parent 098c4b2 commit e8aeaf3

File tree

113 files changed

+950
-676
lines changed

Some content is hidden

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

113 files changed

+950
-676
lines changed

doc/exts/pylint_messages.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ def _register_all_checkers_and_extensions(linter: PyLinter) -> None:
5050
def _get_all_messages(
5151
linter: PyLinter,
5252
) -> Tuple[MessagesDict, OldMessagesDict]:
53-
"""Get all messages registered to a linter and return a dictionary indexed by message
54-
type.
55-
Also return a dictionary of old message and the new messages they can be mapped to.
53+
"""Get all messages registered to a linter and return a dictionary indexed
54+
by message type.
55+
56+
Also return a dictionary of old message and the new messages they
57+
can be mapped to.
5658
"""
5759
messages_dict: MessagesDict = {
5860
"fatal": [],
@@ -202,6 +204,7 @@ def _write_redirect_pages(old_messages: OldMessagesDict) -> None:
202204
# pylint: disable-next=unused-argument
203205
def build_messages_pages(app: Optional[Sphinx]) -> None:
204206
"""Overwrite messages files by printing the documentation to a stream.
207+
205208
Documentation is written in ReST format.
206209
"""
207210
# Create linter, register all checkers and extensions and get all messages

examples/custom_raw.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111

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

1717
__implements__ = IRawChecker

examples/deprecation_checker.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"""Example checker detecting deprecated functions/methods. Following example searches
2-
for usages of deprecated function `deprecated_function` and deprecated method
3-
`MyClass.deprecated_method` from module mymodule:
1+
"""Example checker detecting deprecated functions/methods. Following example
2+
searches for usages of deprecated function `deprecated_function` and deprecated
3+
method `MyClass.deprecated_method` from module mymodule:
44
55
.. code-block:: console
66
$ cat mymodule.py
@@ -59,8 +59,8 @@ class DeprecationChecker(DeprecatedMixin, BaseChecker):
5959
name = "deprecated"
6060

6161
def deprecated_methods(self) -> Set[str]:
62-
"""Callback method called by DeprecatedMixin for every method/function found in
63-
the code.
62+
"""Callback method called by DeprecatedMixin for every method/function
63+
found in the code.
6464
6565
Returns:
6666
collections.abc.Container of deprecated function/method names.

pylint/__init__.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
def run_pylint(argv: Optional[Sequence[str]] = None):
2222
"""Run pylint.
2323
24-
argv can be a sequence of strings normally supplied as arguments on the command line
24+
argv can be a sequence of strings normally supplied as arguments on
25+
the command line
2526
"""
2627
from pylint.lint import Run as PylintRun
2728

@@ -34,7 +35,8 @@ def run_pylint(argv: Optional[Sequence[str]] = None):
3435
def run_epylint(argv: Optional[Sequence[str]] = None):
3536
"""Run epylint.
3637
37-
argv can be a list of strings normally supplied as arguments on the command line
38+
argv can be a list of strings normally supplied as arguments on the
39+
command line
3840
"""
3941
from pylint.epylint import Run as EpylintRun
4042

@@ -44,7 +46,8 @@ def run_epylint(argv: Optional[Sequence[str]] = None):
4446
def run_pyreverse(argv: Optional[Sequence[str]] = None):
4547
"""Run pyreverse.
4648
47-
argv can be a sequence of strings normally supplied as arguments on the command line
49+
argv can be a sequence of strings normally supplied as arguments on
50+
the command line
4851
"""
4952
from pylint.pyreverse.main import Run as PyreverseRun
5053

@@ -54,7 +57,8 @@ def run_pyreverse(argv: Optional[Sequence[str]] = None):
5457
def run_symilar(argv: Optional[Sequence[str]] = None):
5558
"""Run symilar.
5659
57-
argv can be a sequence of strings normally supplied as arguments on the command line
60+
argv can be a sequence of strings normally supplied as arguments on
61+
the command line
5862
"""
5963
from pylint.checkers.similar import Run as SimilarRun
6064

pylint/checkers/__init__.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
5454
The raw_metrics checker has no number associated since it doesn't emit any
5555
messages nor reports. XXX not true, emit a 07 report !
56-
5756
"""
5857

5958
import sys
@@ -75,9 +74,9 @@ def table_lines_from_stats(
7574
old_stats: Optional[LinterStats],
7675
stat_type: Literal["duplicated_lines", "message_types"],
7776
) -> List[str]:
78-
"""Get values listed in <columns> from <stats> and <old_stats>,
79-
and return a formatted list of values, designed to be given to a
80-
ureport.Table object
77+
"""Get values listed in <columns> from <stats> and <old_stats>, and return
78+
a formatted list of values, designed to be given to a ureport.Table
79+
object.
8180
"""
8281
lines: List[str] = []
8382
if stat_type == "duplicated_lines":

pylint/checkers/base.py

+31-27
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101

102102

103103
class NamingStyle:
104-
"""It may seem counterintuitive that single naming style has multiple "accepted"
105-
forms of regular expressions, but we need to special-case stuff like dunder names
106-
in method names.
104+
"""It may seem counterintuitive that single naming style has multiple
105+
"accepted" forms of regular expressions, but we need to special-case stuff
106+
like dunder names in method names.
107107
"""
108108

109109
ANY: Pattern[str] = re.compile(".*")
@@ -231,8 +231,9 @@ class AnyStyle(NamingStyle):
231231

232232

233233
def _redefines_import(node):
234-
"""Detect that the given node (AssignName) is inside an
235-
exception handler and redefines an import from the tryexcept body.
234+
"""Detect that the given node (AssignName) is inside an exception handler
235+
and redefines an import from the tryexcept body.
236+
236237
Returns True if the node redefines an import, False otherwise.
237238
"""
238239
current = node
@@ -267,7 +268,7 @@ def in_loop(node: nodes.NodeNG) -> bool:
267268

268269
def in_nested_list(nested_list, obj):
269270
"""Return true if the object is an element of <nested_list> or of a nested
270-
list
271+
list.
271272
"""
272273
for elmt in nested_list:
273274
if isinstance(elmt, (list, tuple)):
@@ -337,8 +338,8 @@ def _is_multi_naming_match(match, node_type, confidence):
337338
def _get_properties(config):
338339
"""Returns a tuple of property classes and names.
339340
340-
Property classes are fully qualified, such as 'abc.abstractproperty' and
341-
property names are the actual names, such as 'abstract_property'.
341+
Property classes are fully qualified, i.e. 'abc.abstractproperty'
342+
and property names are the actual names, i.e. 'abstract_property'.
342343
"""
343344
property_classes = {BUILTIN_PROPERTY}
344345
property_names = set() # Not returning 'property', it has its own check.
@@ -390,8 +391,8 @@ def _determine_function_name_type(node: nodes.FunctionDef, config=None):
390391
def _has_abstract_methods(node):
391392
"""Determine if the given `node` has abstract methods.
392393
393-
The methods should be made abstract by decorating them
394-
with `abc` decorators.
394+
The methods should be made abstract by decorating them with `abc`
395+
decorators.
395396
"""
396397
return len(utils.unimplemented_abstract_methods(node)) > 0
397398

@@ -784,9 +785,7 @@ def visit_nonlocal(self, node: nodes.Nonlocal) -> None:
784785

785786
@utils.check_messages("abstract-class-instantiated")
786787
def visit_call(self, node: nodes.Call) -> None:
787-
"""Check instantiating abstract class with
788-
abc.ABCMeta as metaclass.
789-
"""
788+
"""Check instantiating abstract class with abc.ABCMeta as metaclass."""
790789
for inferred in infer_all(node.func):
791790
self._check_inferred_class_is_abstract(inferred, node)
792791

@@ -1167,8 +1166,8 @@ def visit_module(self, _: nodes.Module) -> None:
11671166
self.linter.stats.node_count["module"] += 1
11681167

11691168
def visit_classdef(self, _: nodes.ClassDef) -> None:
1170-
"""Check module name, docstring and redefinition
1171-
increment branch counter
1169+
"""Check module name, docstring and redefinition increment branch
1170+
counter.
11721171
"""
11731172
self.linter.stats.node_count["klass"] += 1
11741173

@@ -1306,8 +1305,8 @@ def visit_lambda(self, node: nodes.Lambda) -> None:
13061305

13071306
@utils.check_messages("dangerous-default-value")
13081307
def visit_functiondef(self, node: nodes.FunctionDef) -> None:
1309-
"""Check function name, docstring, arguments, redefinition,
1310-
variable names, max locals
1308+
"""Check function name, docstring, arguments, redefinition, variable
1309+
names, max locals.
13111310
"""
13121311
if node.is_method():
13131312
self.linter.stats.node_count["method"] += 1
@@ -1370,8 +1369,8 @@ def visit_return(self, node: nodes.Return) -> None:
13701369

13711370
@utils.check_messages("unreachable")
13721371
def visit_continue(self, node: nodes.Continue) -> None:
1373-
"""Check is the node has a right sibling (if so, that's some unreachable
1374-
code)
1372+
"""Check is the node has a right sibling (if so, that's some
1373+
unreachable code)
13751374
"""
13761375
self._check_unreachable(node)
13771376

@@ -1389,8 +1388,8 @@ def visit_break(self, node: nodes.Break) -> None:
13891388

13901389
@utils.check_messages("unreachable")
13911390
def visit_raise(self, node: nodes.Raise) -> None:
1392-
"""Check if the node has a right sibling (if so, that's some unreachable
1393-
code)
1391+
"""Check if the node has a right sibling (if so, that's some
1392+
unreachable code)
13941393
"""
13951394
self._check_unreachable(node)
13961395

@@ -1419,7 +1418,8 @@ def _check_misplaced_format_function(self, call_node):
14191418
"eval-used", "exec-used", "bad-reversed-sequence", "misplaced-format-function"
14201419
)
14211420
def visit_call(self, node: nodes.Call) -> None:
1422-
"""Visit a Call node -> check if this is not a disallowed builtin
1421+
"""Visit a Call node -> check if this is not a disallowed builtin.
1422+
14231423
call and check for * or ** use
14241424
"""
14251425
self._check_misplaced_format_function(node)
@@ -1494,8 +1494,9 @@ def _check_unreachable(self, node):
14941494
def _check_not_in_finally(self, node, node_name, breaker_classes=()):
14951495
"""Check that a node is not inside a 'finally' clause of a
14961496
'try...finally' statement.
1497-
If we find a parent which type is in breaker_classes before
1498-
a 'try...finally' block we skip the whole check.
1497+
1498+
If we find a parent which type is in breaker_classes before a
1499+
'try...finally' block we skip the whole check.
14991500
"""
15001501
# if self._tryfinallys is empty, we're not an in try...finally block
15011502
if not self._tryfinallys:
@@ -2263,8 +2264,8 @@ def visit_pass(self, node: nodes.Pass) -> None:
22632264

22642265

22652266
def _is_one_arg_pos_call(call):
2266-
"""Is this a call with exactly 1 argument,
2267-
where that argument is positional?
2267+
"""Is this a call with exactly 1 argument, where that argument is
2268+
positional?
22682269
"""
22692270
return isinstance(call, nodes.Call) and len(call.args) == 1 and not call.keywords
22702271

@@ -2436,7 +2437,9 @@ def _is_nan(node) -> bool:
24362437
)
24372438

24382439
def _check_literal_comparison(self, literal, node: nodes.Compare):
2439-
"""Check if we compare to a literal, which is usually what we do not want to do."""
2440+
"""Check if we compare to a literal, which is usually what we do not
2441+
want to do.
2442+
"""
24402443
is_other_literal = isinstance(literal, (nodes.List, nodes.Dict, nodes.Set))
24412444
is_const = False
24422445
if isinstance(literal, nodes.Const):
@@ -2450,6 +2453,7 @@ def _check_literal_comparison(self, literal, node: nodes.Compare):
24502453

24512454
def _check_logical_tautology(self, node: nodes.Compare):
24522455
"""Check if identifier is compared against itself.
2456+
24532457
:param node: Compare node
24542458
:Example:
24552459
val = 786

pylint/checkers/base_checker.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ def __repr__(self):
6767
return f"{status} '{self.name}' (responsible for '{msgs}')"
6868

6969
def __str__(self):
70-
"""This might be incomplete because multiple class inheriting BaseChecker
71-
can have the same name. Cf MessageHandlerMixIn.get_full_documentation()
70+
"""This might be incomplete because multiple class inheriting
71+
BaseChecker can have the same name.
72+
73+
Cf MessageHandlerMixIn.get_full_documentation()
7274
"""
7375
return self.get_full_documentation(
7476
msgs=self.msgs, options=self.options_and_values(), reports=self.reports

0 commit comments

Comments
 (0)