Skip to content

Commit e355324

Browse files
Some modifications for pep237 with pydocstringformatter (#1792)
Co-authored-by: Daniël van Noord <[email protected]>
1 parent e259af2 commit e355324

13 files changed

+46
-33
lines changed

astroid/astroid_manager.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""
2-
This file contain the global astroid MANAGER, to prevent circular import that happened
2+
This file contain the global astroid MANAGER.
3+
4+
It prevents a circular import that happened
35
when the only possibility to import it was from astroid.__init__.py.
46
57
This AstroidManager is a singleton/borg so it's possible to instantiate an

astroid/brain/brain_boto3.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
33
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt
44

5-
"""Astroid hooks for understanding boto3.ServiceRequest()."""
5+
"""Astroid hooks for understanding ``boto3.ServiceRequest()``."""
6+
67
from astroid import extract_node
78
from astroid.manager import AstroidManager
89
from astroid.nodes.scoped_nodes import ClassDef

astroid/brain/brain_collections.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def __class_getitem__(cls, item): return cls"""
8686

8787
def _looks_like_subscriptable(node: ClassDef) -> bool:
8888
"""
89-
Returns True if the node corresponds to a ClassDef of the Collections.abc module that
90-
supports subscripting
89+
Returns True if the node corresponds to a ClassDef of the Collections.abc module
90+
that supports subscripting.
9191
9292
:param node: ClassDef node
9393
"""

astroid/brain/brain_ctypes.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
def enrich_ctypes_redefined_types():
2121
"""
22-
For each ctypes redefined types, overload 'value' and '_type_' members definition.
22+
For each ctypes redefined types, overload 'value' and '_type_' members
23+
definition.
24+
2325
Overloading 'value' is mandatory otherwise astroid cannot infer the correct type for it.
2426
Overloading '_type_' is necessary because the class definition made here replaces the original
2527
one, in which '_type_' member is defined. Luckily those original class definitions are very short

astroid/brain/brain_numpy_core_einsumfunc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"""
66
Astroid hooks for numpy.core.einsumfunc module:
7-
https://github.com/numpy/numpy/blob/main/numpy/core/einsumfunc.py
7+
https://github.com/numpy/numpy/blob/main/numpy/core/einsumfunc.py.
88
"""
99

1010
from astroid import nodes

astroid/brain/brain_numpy_utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ def numpy_supports_type_hints() -> bool:
2222

2323
def _get_numpy_version() -> tuple[str, str, str]:
2424
"""
25-
Return the numpy version number if numpy can be imported. Otherwise returns
26-
('0', '0', '0')
25+
Return the numpy version number if numpy can be imported.
26+
27+
Otherwise returns ('0', '0', '0')
2728
"""
2829
try:
2930
import numpy # pylint: disable=import-outside-toplevel

astroid/brain/brain_unittest.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
33
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt
44

5-
"""Astroid hooks for unittest module"""
5+
"""Astroid hooks for unittest module."""
66
from astroid.brain.helpers import register_module_extender
77
from astroid.builder import parse
88
from astroid.const import PY38_PLUS
@@ -11,9 +11,11 @@
1111

1212
def IsolatedAsyncioTestCaseImport():
1313
"""
14-
In the unittest package, the IsolatedAsyncioTestCase class is imported lazily, i.e only
15-
when the __getattr__ method of the unittest module is called with 'IsolatedAsyncioTestCase' as
16-
argument. Thus the IsolatedAsyncioTestCase is not imported statically (during import time).
14+
In the unittest package, the IsolatedAsyncioTestCase class is imported lazily.
15+
16+
I.E. only when the ``__getattr__`` method of the unittest module is called with
17+
'IsolatedAsyncioTestCase' as argument. Thus the IsolatedAsyncioTestCase
18+
is not imported statically (during import time).
1719
This function mocks a classical static import of the IsolatedAsyncioTestCase.
1820
1921
(see https://github.com/PyCQA/pylint/issues/4060)

astroid/exceptions.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,10 @@ def __init__(self, target: nodes.NodeNG) -> None:
400400

401401

402402
class StatementMissing(ParentMissingError):
403-
"""Raised when a call to node.statement() does not return a node. This is because
404-
a node in the chain does not have a parent attribute and therefore does not
405-
return a node for statement().
403+
"""Raised when a call to node.statement() does not return a node.
404+
405+
This is because a node in the chain does not have a parent attribute
406+
and therefore does not return a node for statement().
406407
407408
Standard attributes:
408409
target: The node for which the parent lookup failed.

astroid/modutils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,10 @@ def file_info_from_modpath(
339339
path: Sequence[str] | None = None,
340340
context_file: str | None = None,
341341
) -> spec.ModuleSpec:
342-
"""given a mod path (i.e. split module / package name), return the
343-
corresponding file, giving priority to source file over precompiled
344-
file if it exists
342+
"""Given a mod path (i.e. split module / package name), return the
343+
corresponding file.
344+
345+
Giving priority to source file over precompiled file if it exists.
345346
346347
:param modpath:
347348
split module's name (i.e name of a module or package split

astroid/nodes/node_ng.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ def __init__(
126126

127127
self.end_col_offset: int | None = end_col_offset
128128
"""The end column this node appears on in the source code.
129+
129130
Note: This is after the last symbol.
130131
"""
131132

132133
self.position: Position | None = None
133-
"""Position of keyword(s) and name. Used as fallback for block nodes
134-
which might not provide good enough positional information.
135-
E.g. ClassDef, FunctionDef.
134+
"""Position of keyword(s) and name.
135+
136+
Used as fallback for block nodes which might not provide good
137+
enough positional information. E.g. ClassDef, FunctionDef.
136138
"""
137139

138140
def infer(
@@ -262,7 +264,7 @@ def get_children(self) -> Iterator[NodeNG]:
262264
yield from ()
263265

264266
def last_child(self) -> NodeNG | None:
265-
"""An optimized version of list(get_children())[-1]"""
267+
"""An optimized version of list(get_children())[-1]."""
266268
for field in self._astroid_fields[::-1]:
267269
attr = getattr(self, field)
268270
if not attr: # None or empty list / tuple
@@ -349,6 +351,7 @@ def frame(
349351

350352
def scope(self) -> nodes.LocalsDictNodeNG:
351353
"""The first parent node defining a new scope.
354+
352355
These can be Module, FunctionDef, ClassDef, Lambda, or GeneratorExp nodes.
353356
354357
:returns: The first parent scope node.
@@ -591,7 +594,7 @@ def _infer_name(self, frame, name):
591594
def _infer(
592595
self, context: InferenceContext | None = None, **kwargs: Any
593596
) -> Generator[InferenceResult, None, InferenceErrorInfo | None]:
594-
"""we don't know how to resolve a statement by default"""
597+
"""We don't know how to resolve a statement by default."""
595598
# this method is overridden by most concrete classes
596599
raise InferenceError(
597600
"No inference function for {node!r}.", node=self, context=context
@@ -696,7 +699,9 @@ def _repr_tree(node, result, done, cur_indent="", depth=1):
696699
@_repr_tree.register(tuple)
697700
@_repr_tree.register(list)
698701
def _repr_seq(node, result, done, cur_indent="", depth=1):
699-
"""Outputs a representation of a sequence that's contained within an AST."""
702+
"""Outputs a representation of a sequence that's contained within an
703+
AST.
704+
"""
700705
cur_indent += indent
701706
result.append("[")
702707
if not node:

astroid/objects.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343

4444
class FrozenSet(node_classes.BaseContainer):
45-
"""class representing a FrozenSet composite node"""
45+
"""Class representing a FrozenSet composite node."""
4646

4747
def pytype(self) -> Literal["builtins.frozenset"]:
4848
return "builtins.frozenset"
@@ -225,7 +225,7 @@ def getattr(self, name, context: InferenceContext | None = None):
225225

226226

227227
class ExceptionInstance(bases.Instance):
228-
"""Class for instances of exceptions
228+
"""Class for instances of exceptions.
229229
230230
It has special treatment for some of the exceptions's attributes,
231231
which are transformed at runtime into certain concrete objects, such as
@@ -242,7 +242,7 @@ def special_attributes(self):
242242

243243

244244
class DictInstance(bases.Instance):
245-
"""Special kind of instances for dictionaries
245+
"""Special kind of instances for dictionaries.
246246
247247
This instance knows the underlying object model of the dictionaries, which means
248248
that methods such as .values or .items can be properly inferred.
@@ -271,7 +271,7 @@ class DictValues(bases.Proxy):
271271

272272

273273
class PartialFunction(scoped_nodes.FunctionDef):
274-
"""A class representing partial function obtained via functools.partial"""
274+
"""A class representing partial function obtained via functools.partial."""
275275

276276
@decorators.deprecate_arguments(doc="Use the postinit arg 'doc_node' instead")
277277
def __init__(
@@ -322,7 +322,7 @@ def qname(self) -> str:
322322

323323

324324
class Property(scoped_nodes.FunctionDef):
325-
"""Class representing a Python property"""
325+
"""Class representing a Python property."""
326326

327327
@decorators.deprecate_arguments(doc="Use the postinit arg 'doc_node' instead")
328328
def __init__(

astroid/test_utils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919

2020
def require_version(minver: str = "0.0.0", maxver: str = "4.0.0") -> Callable:
21-
"""Compare version of python interpreter to the given one.
22-
Skip the test if older.
23-
"""
21+
"""Compare version of python interpreter to the given one and skips the test if older."""
2422

2523
def parse(python_version: str) -> tuple[int, ...]:
2624
try:

astroid/transforms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def unregister_transform(self, node_class, transform, predicate=None) -> None:
8181
self.transforms[node_class].remove((transform, predicate))
8282

8383
def visit(self, module):
84-
"""Walk the given astroid *tree* and transform each encountered node
84+
"""Walk the given astroid *tree* and transform each encountered node.
8585
8686
Only the nodes which have transforms registered will actually
8787
be replaced or changed.

0 commit comments

Comments
 (0)