Skip to content

Commit fffde57

Browse files
DanielNoordPierre-Sassoulas
authored andcommitted
Format docstrings with pydocstringformatter
1 parent 15c8825 commit fffde57

Some content is hidden

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

64 files changed

+208
-264
lines changed

examples/custom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class MyAstroidChecker(BaseChecker):
5252
def visit_call(self, node: nodes.Call) -> None:
5353
"""Called when a :class:`.nodes.Call` node is visited.
5454
55-
See :mod:`astroid` for the description of available nodes."""
55+
See :mod:`astroid` for the description of available nodes.
56+
"""
5657
if not (
5758
isinstance(node.func, nodes.Attribute)
5859
and isinstance(node.func.expr, nodes.Name)

examples/deprecation_checker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Example checker detecting deprecated functions/methods. Following example searches for usages of
1+
"""Example checker detecting deprecated functions/methods. Following example searches for usages of
32
deprecated function `deprecated_function` and deprecated method `MyClass.deprecated_method`
43
from module mymodule:
54

pylint/checkers/base.py

Lines changed: 7 additions & 8 deletions
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
106-
in method names."""
106+
in method names.
107+
"""
107108

108109
ANY: Pattern[str] = re.compile(".*")
109110
CLASS_NAME_RGX: Pattern[str] = ANY
@@ -278,8 +279,7 @@ def in_nested_list(nested_list, obj):
278279

279280

280281
def _get_break_loop_node(break_node):
281-
"""
282-
Returns the loop node that holds the break node in arguments.
282+
"""Returns the loop node that holds the break node in arguments.
283283
284284
Args:
285285
break_node (astroid.Break): the break node of interest.
@@ -300,8 +300,7 @@ def _get_break_loop_node(break_node):
300300

301301

302302
def _loop_exits_early(loop):
303-
"""
304-
Returns true if a loop may end with a break statement.
303+
"""Returns true if a loop may end with a break statement.
305304
306305
Args:
307306
loop (astroid.For, astroid.While): the loop node inspected.
@@ -389,8 +388,7 @@ def _determine_function_name_type(node: nodes.FunctionDef, config=None):
389388

390389

391390
def _has_abstract_methods(node):
392-
"""
393-
Determine if the given `node` has abstract methods.
391+
"""Determine if the given `node` has abstract methods.
394392
395393
The methods should be made abstract by decorating them
396394
with `abc` decorators.
@@ -1496,7 +1494,8 @@ def _check_not_in_finally(self, node, node_name, breaker_classes=()):
14961494
"""check that a node is not inside a 'finally' clause of a
14971495
'try...finally' statement.
14981496
If we find a parent which type is in breaker_classes before
1499-
a 'try...finally' block we skip the whole check."""
1497+
a 'try...finally' block we skip the whole check.
1498+
"""
15001499
# if self._tryfinallys is empty, we're not an in try...finally block
15011500
if not self._tryfinallys:
15021501
return

pylint/checkers/base_checker.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class BaseChecker(OptionsProviderMixIn):
5050
def __init__(self, linter=None):
5151
"""checker instances should have the linter as argument
5252
53-
:param ILinter linter: is an object implementing ILinter."""
53+
:param ILinter linter: is an object implementing ILinter.
54+
"""
5455
if self.name is not None:
5556
self.name = self.name.lower()
5657
super().__init__()
@@ -67,7 +68,8 @@ def __repr__(self):
6768

6869
def __str__(self):
6970
"""This might be incomplete because multiple class inheriting BaseChecker
70-
can have the same name. Cf MessageHandlerMixIn.get_full_documentation()"""
71+
can have the same name. Cf MessageHandlerMixIn.get_full_documentation()
72+
"""
7173
return self.get_full_documentation(
7274
msgs=self.msgs, options=self.options_and_values(), reports=self.reports
7375
)
@@ -132,7 +134,8 @@ def check_consistency(self):
132134
checker.
133135
134136
:raises InvalidMessageError: If the checker id in the messages are not
135-
always the same."""
137+
always the same.
138+
"""
136139
checker_id = None
137140
existing_ids = []
138141
for message in self.messages:

pylint/checkers/classes/class_checker.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ class _DefaultMissing:
186186

187187

188188
def _has_different_parameters_default_value(original, overridden):
189-
"""
190-
Check if original and overridden methods arguments have different default values
189+
"""Check if original and overridden methods arguments have different default values
191190
192191
Return True if one of the overridden arguments has a default
193192
value different from the default value of the original argument
@@ -821,8 +820,7 @@ def _check_consistent_mro(self, node):
821820
pass
822821

823822
def _check_proper_bases(self, node):
824-
"""
825-
Detect that a class inherits something which is not
823+
"""Detect that a class inherits something which is not
826824
a class or a type.
827825
"""
828826
for base in node.bases:
@@ -1655,9 +1653,7 @@ def _check_protected_attribute_access(self, node: nodes.Attribute):
16551653

16561654
@staticmethod
16571655
def _is_called_inside_special_method(node: nodes.NodeNG) -> bool:
1658-
"""
1659-
Returns true if the node is located inside a special (aka dunder) method
1660-
"""
1656+
"""Returns true if the node is located inside a special (aka dunder) method"""
16611657
try:
16621658
frame_name = node.frame().name
16631659
except AttributeError:

pylint/checkers/classes/special_methods_checker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222

2323
def _safe_infer_call_result(node, caller, context=None):
24-
"""
25-
Safely infer the return value of a function.
24+
"""Safely infer the return value of a function.
2625
2726
Returns None if inference failed or if there is some ambiguity (more than
2827
one node has been inferred). Otherwise, returns inferred value.

pylint/checkers/ellipsis_checker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Ellipsis checker for Python code
2-
"""
1+
"""Ellipsis checker for Python code"""
32
from typing import TYPE_CHECKING
43

54
from astroid import nodes

pylint/checkers/exceptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def predicate(obj):
5757

5858

5959
def _annotated_unpack_infer(stmt, context=None):
60-
"""
61-
Recursively generate nodes inferred by the given statement.
60+
"""Recursively generate nodes inferred by the given statement.
6261
If the inferred value is a list or a tuple, recurse on the elements.
6362
Returns an iterator which yields tuples in the format
6463
('original node', 'inferred node').

pylint/checkers/format.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,7 @@ def _check_multi_statement_line(self, node, line):
669669
self._visited_lines[line] = 2
670670

671671
def check_line_ending(self, line: str, i: int) -> None:
672-
"""
673-
Check that the final newline is not missing and that there is no trailing whitespace.
674-
"""
672+
"""Check that the final newline is not missing and that there is no trailing whitespace."""
675673
if not line.endswith("\n"):
676674
self.add_message("missing-final-newline", line=i)
677675
return
@@ -683,9 +681,7 @@ def check_line_ending(self, line: str, i: int) -> None:
683681
)
684682

685683
def check_line_length(self, line: str, i: int, checker_off: bool) -> None:
686-
"""
687-
Check that the line length is less than the authorized value
688-
"""
684+
"""Check that the line length is less than the authorized value"""
689685
max_chars = self.config.max_line_length
690686
ignore_long_line = self.config.ignore_long_lines
691687
line = line.rstrip()
@@ -697,9 +693,7 @@ def check_line_length(self, line: str, i: int, checker_off: bool) -> None:
697693

698694
@staticmethod
699695
def remove_pylint_option_from_lines(options_pattern_obj) -> str:
700-
"""
701-
Remove the `# pylint ...` pattern from lines
702-
"""
696+
"""Remove the `# pylint ...` pattern from lines"""
703697
lines = options_pattern_obj.string
704698
purged_lines = (
705699
lines[: options_pattern_obj.start(1)].rstrip()
@@ -709,9 +703,7 @@ def remove_pylint_option_from_lines(options_pattern_obj) -> str:
709703

710704
@staticmethod
711705
def is_line_length_check_activated(pylint_pattern_match_object) -> bool:
712-
"""
713-
Return true if the line length check is activated
714-
"""
706+
"""Return true if the line length check is activated"""
715707
try:
716708
for pragma in parse_pragma(pylint_pattern_match_object.group(2)):
717709
if pragma.action == "disable" and "line-too-long" in pragma.messages:
@@ -723,9 +715,7 @@ def is_line_length_check_activated(pylint_pattern_match_object) -> bool:
723715

724716
@staticmethod
725717
def specific_splitlines(lines: str) -> List[str]:
726-
"""
727-
Split lines according to universal newlines except those in a specific sets
728-
"""
718+
"""Split lines according to universal newlines except those in a specific sets"""
729719
unsplit_ends = {
730720
"\v",
731721
"\x0b",
@@ -749,11 +739,10 @@ def specific_splitlines(lines: str) -> List[str]:
749739
return res
750740

751741
def check_lines(self, lines: str, lineno: int) -> None:
752-
"""
753-
Check lines have :
754-
- a final newline
755-
- no trailing whitespace
756-
- less than a maximum number of characters
742+
"""Check lines have :
743+
- a final newline
744+
- no trailing whitespace
745+
- less than a maximum number of characters
757746
"""
758747
# we're first going to do a rough check whether any lines in this set
759748
# go over the line limit. If none of them do, then we don't need to

pylint/checkers/logging.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2424
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
2525

26-
"""checker for use of Python logging
27-
"""
26+
"""checker for use of Python logging"""
2827
import string
2928
from typing import TYPE_CHECKING, Set
3029

@@ -295,9 +294,7 @@ def _helper_string(self, node):
295294

296295
@staticmethod
297296
def _is_operand_literal_str(operand):
298-
"""
299-
Return True if the operand in argument is a literal string
300-
"""
297+
"""Return True if the operand in argument is a literal string"""
301298
return isinstance(operand, nodes.Const) and operand.name == "str"
302299

303300
def _check_call_func(self, node: nodes.Call):

0 commit comments

Comments
 (0)