summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--astroid/brain/brain_numpy_core_multiarray.py13
-rw-r--r--astroid/brain/brain_typing.py7
-rw-r--r--astroid/decorators.py3
-rw-r--r--astroid/interpreter/_import/spec.py4
-rw-r--r--astroid/node_classes.py3
-rw-r--r--astroid/rebuilder.py3
-rw-r--r--astroid/scoped_nodes.py3
-rw-r--r--setup.cfg4
-rw-r--r--tests/unittest_brain.py6
-rw-r--r--tests/unittest_brain_ctypes.py8
-rw-r--r--tests/unittest_modutils.py2
-rw-r--r--tests/unittest_nodes_lineno.py7
12 files changed, 40 insertions, 23 deletions
diff --git a/astroid/brain/brain_numpy_core_multiarray.py b/astroid/brain/brain_numpy_core_multiarray.py
index 487ec471..dbdb24ea 100644
--- a/astroid/brain/brain_numpy_core_multiarray.py
+++ b/astroid/brain/brain_numpy_core_multiarray.py
@@ -47,10 +47,15 @@ METHODS_TO_BE_INFERRED = {
return numpy.ndarray([0, 0])""",
"bincount": """def bincount(x, weights=None, minlength=0):
return numpy.ndarray([0, 0])""",
- "busday_count": """def busday_count(begindates, enddates, weekmask='1111100', holidays=[], busdaycal=None, out=None):
- return numpy.ndarray([0, 0])""",
- "busday_offset": """def busday_offset(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaycal=None, out=None):
- return numpy.ndarray([0, 0])""",
+ "busday_count": """def busday_count(
+ begindates, enddates, weekmask='1111100', holidays=[], busdaycal=None, out=None
+ ):
+ return numpy.ndarray([0, 0])""",
+ "busday_offset": """def busday_offset(
+ dates, offsets, roll='raise', weekmask='1111100', holidays=None,
+ busdaycal=None, out=None
+ ):
+ return numpy.ndarray([0, 0])""",
"can_cast": """def can_cast(from_, to, casting='safe'):
return True""",
"copyto": """def copyto(dst, src, casting='same_kind', where=True):
diff --git a/astroid/brain/brain_typing.py b/astroid/brain/brain_typing.py
index 807ba96e..b34b8bec 100644
--- a/astroid/brain/brain_typing.py
+++ b/astroid/brain/brain_typing.py
@@ -240,7 +240,7 @@ def _forbid_class_getitem_access(node: ClassDef) -> None:
def full_raiser(origin_func, attr, *args, **kwargs):
"""
Raises an AttributeInferenceError in case of access to __class_getitem__ method.
- Otherwise just call origin_func.
+ Otherwise, just call origin_func.
"""
if attr == "__class_getitem__":
raise AttributeInferenceError("__class_getitem__ access is not allowed")
@@ -248,8 +248,9 @@ def _forbid_class_getitem_access(node: ClassDef) -> None:
try:
node.getattr("__class_getitem__")
- # If we are here, then we are sure to modify object that do have __class_getitem__ method (which origin is one the
- # protocol defined in collections module) whereas the typing module consider it should not
+ # If we are here, then we are sure to modify an object that does have
+ # __class_getitem__ method (which origin is the protocol defined in
+ # collections module) whereas the typing module considers it should not.
# We do not want __class_getitem__ to be found in the classdef
partial_raiser = partial(full_raiser, node.getattr)
node.getattr = partial_raiser
diff --git a/astroid/decorators.py b/astroid/decorators.py
index e9cc3292..abdc1270 100644
--- a/astroid/decorators.py
+++ b/astroid/decorators.py
@@ -208,7 +208,8 @@ if util.check_warnings_filter():
):
warnings.warn(
f"'{arg}' will be a required argument for "
- f"'{args[0].__class__.__qualname__}.{func.__name__}' in astroid {astroid_version} "
+ f"'{args[0].__class__.__qualname__}.{func.__name__}'"
+ f" in astroid {astroid_version} "
f"('{arg}' should be of type: '{type_annotation}')",
DeprecationWarning,
)
diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py
index 5350916b..ce6d2416 100644
--- a/astroid/interpreter/_import/spec.py
+++ b/astroid/interpreter/_import/spec.py
@@ -121,7 +121,9 @@ class ImportlibFinder(Finder):
else:
try:
spec = importlib.util.find_spec(modname)
- if spec and spec.loader is importlib.machinery.FrozenImporter: # type: ignore[comparison-overlap]
+ if (
+ spec and spec.loader is importlib.machinery.FrozenImporter
+ ): # noqa: E501 # type: ignore[comparison-overlap]
# No need for BuiltinImporter; builtins handled above
return ModuleSpec(
name=modname,
diff --git a/astroid/node_classes.py b/astroid/node_classes.py
index 3711309b..59bb0109 100644
--- a/astroid/node_classes.py
+++ b/astroid/node_classes.py
@@ -92,6 +92,7 @@ from astroid.nodes.node_classes import ( # pylint: disable=redefined-builtin (E
# Please remove astroid/scoped_nodes.py|astroid/node_classes.py in autoflake
# exclude when removing this file.
warnings.warn(
- "The 'astroid.node_classes' module is deprecated and will be replaced by 'astroid.nodes' in astroid 3.0.0",
+ "The 'astroid.node_classes' module is deprecated and will be replaced by "
+ "'astroid.nodes' in astroid 3.0.0",
DeprecationWarning,
)
diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py
index 070b9db8..757feaa4 100644
--- a/astroid/rebuilder.py
+++ b/astroid/rebuilder.py
@@ -1332,7 +1332,8 @@ class TreeRebuilder:
)
# Prohibit a local save if we are in an ExceptHandler.
if not isinstance(parent, nodes.ExceptHandler):
- # mypy doesn't recognize that newnode has to be AssignAttr because it doesn't support ParamSpec
+ # mypy doesn't recognize that newnode has to be AssignAttr because it
+ # doesn't support ParamSpec
# See https://github.com/python/mypy/issues/8645
self._delayed_assattr.append(newnode) # type: ignore[arg-type]
else:
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index 677f8925..1e3fbf31 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -28,6 +28,7 @@ from astroid.nodes.scoped_nodes import (
# Please remove astroid/scoped_nodes.py|astroid/node_classes.py in autoflake
# exclude when removing this file.
warnings.warn(
- "The 'astroid.scoped_nodes' module is deprecated and will be replaced by 'astroid.nodes' in astroid 3.0.0",
+ "The 'astroid.scoped_nodes' module is deprecated and will be replaced by "
+ "'astroid.nodes' in astroid 3.0.0",
DeprecationWarning,
)
diff --git a/setup.cfg b/setup.cfg
index 9fda04b0..74d9078e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -15,7 +15,9 @@ extend-ignore =
W503, # Incompatible with black
B901 # Combine yield and return statements in one function
max-complexity = 83
-max-line-length = 138
+max-line-length = 120
+# per-file-ignores =
+# astroid/brain/brain_numpy_core_multiarray.py: E501, B950
select = B,C,E,F,W,T4,B9
# Required for flake8-typing-imports (v1.12.0)
# The plugin doesn't yet read the value from pyproject.toml
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py
index 07d17c4c..2f88fc54 100644
--- a/tests/unittest_brain.py
+++ b/tests/unittest_brain.py
@@ -1473,7 +1473,8 @@ class CollectionsBrain(unittest.TestCase):
@test_utils.require_version(minver="3.9")
def test_collections_object_subscriptable_3(self):
- """With python39 ByteString class of the colletions module is subscritable (but not the same class from typing module)"""
+ """With Python 3.9 the ByteString class of the collections module is subscritable
+ (but not the same class from typing module)"""
right_node = builder.extract_node(
"""
import collections.abc
@@ -1984,7 +1985,8 @@ class TypingBrain(unittest.TestCase):
)
def test_typing_object_notsubscriptable_3(self):
- """Until python39 ByteString class of the typing module is not subscritable (whereas it is in the collections module)"""
+ """Until python39 ByteString class of the typing module is not
+ subscriptable (whereas it is in the collections' module)"""
right_node = builder.extract_node(
"""
import typing
diff --git a/tests/unittest_brain_ctypes.py b/tests/unittest_brain_ctypes.py
index cae95409..dbcf54d9 100644
--- a/tests/unittest_brain_ctypes.py
+++ b/tests/unittest_brain_ctypes.py
@@ -10,7 +10,8 @@ from astroid import extract_node, nodes
pytestmark = pytest.mark.skipif(
hasattr(sys, "pypy_version_info"),
- reason="pypy has its own implementation of _ctypes module which is different from the one of cpython",
+ reason="pypy has its own implementation of _ctypes module which is different "
+ "from the one of cpython",
)
@@ -83,8 +84,9 @@ def test_ctypes_redefined_types_members(c_type, builtin_type, type_code):
def test_cdata_member_access() -> None:
"""
- Test that the base members are still accessible. Each redefined ctypes type inherits from _SimpleCData which itself
- inherits from _CData. Checks that _CData members are accessibles
+ Test that the base members are still accessible. Each redefined ctypes type
+ inherits from _SimpleCData which itself inherits from _CData. Checks that
+ _CData members are accessible.
"""
src = """
import ctypes
diff --git a/tests/unittest_modutils.py b/tests/unittest_modutils.py
index 82bb7660..6f8d8033 100644
--- a/tests/unittest_modutils.py
+++ b/tests/unittest_modutils.py
@@ -411,7 +411,6 @@ class GetModuleFilesTest(unittest.TestCase):
class ExtensionPackageWhitelistTest(unittest.TestCase):
def test_is_module_name_part_of_extension_package_whitelist_true(self) -> None:
- """Test that the is_module_name_part_of_extension_package_whitelist function returns True when needed"""
self.assertTrue(
modutils.is_module_name_part_of_extension_package_whitelist(
"numpy", {"numpy"}
@@ -429,7 +428,6 @@ class ExtensionPackageWhitelistTest(unittest.TestCase):
)
def test_is_module_name_part_of_extension_package_whitelist_success(self) -> None:
- """Test that the is_module_name_part_of_extension_package_whitelist function returns False when needed"""
self.assertFalse(
modutils.is_module_name_part_of_extension_package_whitelist(
"numpy", {"numpy.core"}
diff --git a/tests/unittest_nodes_lineno.py b/tests/unittest_nodes_lineno.py
index c1c089ac..2cc8094d 100644
--- a/tests/unittest_nodes_lineno.py
+++ b/tests/unittest_nodes_lineno.py
@@ -661,9 +661,10 @@ class TestLinenoColOffset:
assert isinstance(f1.args.kwonlyargs[0], nodes.AssignName)
assert (f1.args.kwonlyargs[0].lineno, f1.args.kwonlyargs[0].col_offset) == (4, 4)
assert (f1.args.kwonlyargs[0].end_lineno, f1.args.kwonlyargs[0].end_col_offset) == (4, 16)
- assert isinstance(f1.args.kwonlyargs_annotations[0], nodes.Name)
- assert (f1.args.kwonlyargs_annotations[0].lineno, f1.args.kwonlyargs_annotations[0].col_offset) == (4, 13)
- assert (f1.args.kwonlyargs_annotations[0].end_lineno, f1.args.kwonlyargs_annotations[0].end_col_offset) == (4, 16)
+ annotations = f1.args.kwonlyargs_annotations
+ assert isinstance(annotations[0], nodes.Name)
+ assert (annotations[0].lineno, annotations[0].col_offset) == (4, 13)
+ assert (annotations[0].end_lineno, annotations[0].end_col_offset) == (4, 16)
assert isinstance(f1.args.kw_defaults[0], nodes.Const)
assert (f1.args.kw_defaults[0].lineno, f1.args.kw_defaults[0].col_offset) == (4, 19)
assert (f1.args.kw_defaults[0].end_lineno, f1.args.kw_defaults[0].end_col_offset) == (4, 20)