Skip to content

Commit 850fa7c

Browse files
[style] Apply pydocstringformatter where it's not problematic
1 parent 4dba2db commit 850fa7c

32 files changed

+181
-162
lines changed

astroid/__init__.py

+1-1
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-
"""Python Abstract Syntax Tree New Generation
5+
"""Python Abstract Syntax Tree New Generation.
66
77
The aim of this module is to provide a common base representation of
88
python source code for projects such as pychecker, pyreverse,

astroid/_ast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def parse(self, string: str, type_comments: bool = True) -> ast.Module:
5151

5252

5353
def parse_function_type_comment(type_comment: str) -> FunctionType | None:
54-
"""Given a correct type comment, obtain a FunctionType object"""
54+
"""Given a correct type comment, obtain a FunctionType object."""
5555
if _ast_py3 is None:
5656
return None
5757

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, to prevent circular import that
3+
happened.
4+
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-2
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 understanding boto3.ServiceRequest()"""
5+
"""Astroid hooks for understanding ``boto3.ServiceRequest()``."""
66
from astroid import extract_node
77
from astroid.manager import AstroidManager
88
from astroid.nodes.scoped_nodes import ClassDef
@@ -11,7 +11,7 @@
1111

1212

1313
def service_request_transform(node):
14-
"""Transform ServiceResource to look like dynamic classes"""
14+
"""Transform ServiceResource to look like dynamic classes."""
1515
code = """
1616
def __getattr__(self, attr):
1717
return 0

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_dateutil.py

+1-1
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 dateutil"""
5+
"""Astroid hooks for dateutil."""
66

77
import textwrap
88

astroid/brain/brain_functools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _looks_like_lru_cache(node) -> bool:
137137

138138

139139
def _looks_like_functools_member(node, member) -> bool:
140-
"""Check if the given Call node is a functools.partial call"""
140+
"""Check if the given Call node is a functools.partial call."""
141141
if isinstance(node.func, Name):
142142
return node.func.name == member
143143
if isinstance(node.func, Attribute):

astroid/brain/brain_hypothesis.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def a_strategy(draw):
1515
return draw(st.integers())
1616
1717
a_strategy()
18-
1918
"""
2019
from astroid.manager import AstroidManager
2120
from astroid.nodes.scoped_nodes import FunctionDef
@@ -39,7 +38,8 @@ def is_decorated_with_st_composite(node) -> bool:
3938

4039
def remove_draw_parameter_from_composite_strategy(node):
4140
"""Given that the FunctionDef is decorated with @st.composite, remove the
42-
first argument (`draw`) - it's always supplied by Hypothesis so we don't
41+
first argument (`draw`) - it's always supplied by Hypothesis so we don't.
42+
4343
need to emit the no-value-for-parameter lint.
4444
"""
4545
del node.args.args[0]

astroid/brain/brain_io.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414

1515
def _generic_io_transform(node, name, cls):
16-
"""Transform the given name, by adding the given *class* as a member of the node."""
16+
"""Transform the given name, by adding the given *class* as a member of the
17+
node.
18+
"""
1719

1820
io_module = AstroidManager().ast_from_module_name("_io")
1921
attribute_object = io_module[cls]

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

+5-6
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-
"""Different utilities for the numpy brains"""
5+
"""Different utilities for the numpy brains."""
66

77
from __future__ import annotations
88

@@ -15,17 +15,16 @@
1515

1616

1717
def numpy_supports_type_hints() -> bool:
18-
"""
19-
Returns True if numpy supports type hints
20-
"""
18+
"""Returns True if numpy supports type hints."""
2119
np_ver = _get_numpy_version()
2220
return np_ver and np_ver > NUMPY_VERSION_TYPE_HINTS_SUPPORT
2321

2422

2523
def _get_numpy_version() -> tuple[str, str, str]:
2624
"""
27-
Return the numpy version number if numpy can be imported. Otherwise returns
28-
('0', '0', '0')
25+
Return the numpy version number if numpy can be imported.
26+
27+
Otherwise returns ('0', '0', '0')
2928
"""
3029
try:
3130
import numpy # pylint: disable=import-outside-toplevel

astroid/brain/brain_re.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def _looks_like_pattern_or_match(node: nodes.Call) -> bool:
7575

7676

7777
def infer_pattern_match(node: nodes.Call, ctx: context.InferenceContext | None = None):
78-
"""Infer re.Pattern and re.Match as classes. For PY39+ add `__class_getitem__`."""
78+
"""Infer re.Pattern and re.Match as classes.
79+
80+
For PY39+ add `__class_getitem__`.
81+
"""
7982
class_def = nodes.ClassDef(
8083
name=node.parent.targets[0].name,
8184
lineno=node.lineno,

astroid/brain/brain_responses.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
:class:`responses.RequestsMock`.
1010
1111
See: https://github.com/getsentry/responses/blob/master/responses.py
12-
1312
"""
1413
from astroid.brain.helpers import register_module_extender
1514
from astroid.builder import parse

astroid/brain/brain_six.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _looks_like_decorated_with_six_add_metaclass(node) -> bool:
167167

168168

169169
def transform_six_add_metaclass(node): # pylint: disable=inconsistent-return-statements
170-
"""Check if the given class node is decorated with *six.add_metaclass*
170+
"""Check if the given class node is decorated with *six.add_metaclass*.
171171
172172
If so, inject its argument as the metaclass of the underlying class.
173173
"""
@@ -213,7 +213,7 @@ def _looks_like_nested_from_six_with_metaclass(node) -> bool:
213213

214214

215215
def transform_six_with_metaclass(node):
216-
"""Check if the given class node is defined with *six.with_metaclass*
216+
"""Check if the given class node is defined with *six.with_metaclass*.
217217
218218
If so, inject its argument as the metaclass of the underlying class.
219219
"""

astroid/brain/brain_type.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
def _looks_like_type_subscript(node) -> bool:
3333
"""
34-
Try to figure out if a Name node is used inside a type related subscript
34+
Try to figure out if a Name node is used inside a type related subscript.
3535
3636
:param node: node to check
3737
:type node: astroid.nodes.node_classes.NodeNG
@@ -44,7 +44,7 @@ def _looks_like_type_subscript(node) -> bool:
4444

4545
def infer_type_sub(node, context: InferenceContext | None = None):
4646
"""
47-
Infer a type[...] subscript
47+
Infer a type[...] subscript.
4848
4949
:param node: node to infer
5050
:type node: astroid.nodes.node_classes.NodeNG

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

+16-13
Original file line numberDiff line numberDiff line change
@@ -2,8 +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-
"""this module contains exceptions used in the astroid library
6-
"""
5+
"""This module contains exceptions used in the astroid library."""
76

87
from __future__ import annotations
98

@@ -49,7 +48,7 @@
4948

5049

5150
class AstroidError(Exception):
52-
"""base exception class for all astroid related exceptions
51+
"""Base exception class for all astroid related exceptions.
5352
5453
AstroidError and its subclasses are structured, intended to hold
5554
objects representing state when the exception is thrown. Field
@@ -73,7 +72,7 @@ def __str__(self) -> str:
7372

7473

7574
class AstroidBuildingError(AstroidError):
76-
"""exception class when we are unable to build an astroid representation
75+
"""Exception class when we are unable to build an astroid representation.
7776
7877
Standard attributes:
7978
modname: Name of the module that AST construction failed for.
@@ -140,8 +139,8 @@ def __init__(
140139

141140

142141
class NoDefault(AstroidError):
143-
"""raised by function's `default_value` method when an argument has
144-
no default value
142+
"""Raised by function's `default_value` method when an argument has
143+
no default value.
145144
146145
Standard attributes:
147146
func: Function node.
@@ -228,7 +227,7 @@ def __str__(self) -> str:
228227

229228

230229
class InferenceError(ResolveError): # pylint: disable=too-many-instance-attributes
231-
"""raised when we are unable to infer a node
230+
"""Raised when we are unable to infer a node.
232231
233232
Standard attributes:
234233
node: The node inference was called on.
@@ -332,13 +331,15 @@ def __init__(
332331

333332

334333
class UseInferenceDefault(Exception):
335-
"""exception to be raised in custom inference function to indicate that it
336-
should go back to the default behaviour
334+
"""Exception to be raised in custom inference function to indicate that it
335+
should go back to the default behaviour.
337336
"""
338337

339338

340339
class _NonDeducibleTypeHierarchy(Exception):
341-
"""Raised when is_subtype / is_supertype can't deduce the relation between two types."""
340+
"""Raised when is_subtype / is_supertype can't deduce the relation between two
341+
types.
342+
"""
342343

343344

344345
class AstroidIndexError(AstroidError):
@@ -380,14 +381,14 @@ class AstroidValueError(AstroidError):
380381

381382

382383
class InferenceOverwriteError(AstroidError):
383-
"""Raised when an inference tip is overwritten
384+
"""Raised when an inference tip is overwritten.
384385
385386
Currently only used for debugging.
386387
"""
387388

388389

389390
class ParentMissingError(AstroidError):
390-
"""Raised when a node which is expected to have a parent attribute is missing one
391+
"""Raised when a node which is expected to have a parent attribute is missing one.
391392
392393
Standard attributes:
393394
target: The node for which the parent lookup failed.
@@ -399,7 +400,9 @@ def __init__(self, target: nodes.NodeNG) -> None:
399400

400401

401402
class StatementMissing(ParentMissingError):
402-
"""Raised when a call to node.statement() does not return a node. This is because
403+
"""Raised when a call to node.statement() does not return a node.
404+
405+
This is because
403406
a node in the chain does not have a parent attribute and therefore does not
404407
return a node for statement().
405408

astroid/inference_tip.py

+2-2
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-
"""Transform utilities (filters and decorator)"""
5+
"""Transform utilities (filters and decorator)."""
66

77
from __future__ import annotations
88

@@ -32,7 +32,7 @@ def clear_inference_tip_cache() -> None:
3232
def _inference_tip_cached(
3333
func: InferFn, instance: None, args: typing.Any, kwargs: typing.Any
3434
) -> Iterator[InferOptions]:
35-
"""Cache decorator used for inference tips"""
35+
"""Cache decorator used for inference tips."""
3636
node = args[0]
3737
try:
3838
result = _cache[func, node]

astroid/interpreter/_import/spec.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ModuleType(enum.Enum):
4444

4545

4646
class ModuleSpec(NamedTuple):
47-
"""Defines a class similar to PEP 420's ModuleSpec
47+
"""Defines a class similar to PEP 420's ModuleSpec.
4848
4949
A module spec defines a name of a module, its type, location
5050
and where submodules can be found, if the module is a package.
@@ -71,7 +71,7 @@ def find_module(
7171
processed: list[str],
7272
submodule_path: Sequence[str] | None,
7373
) -> ModuleSpec | None:
74-
"""Find the given module
74+
"""Find the given module.
7575
7676
Each finder is responsible for each protocol of finding, as long as
7777
they all return a ModuleSpec.

0 commit comments

Comments
 (0)