Skip to content

Commit 8620ae1

Browse files
authoredSep 30, 2024
Enable design complexity checks (#2591)
1 parent 36094ed commit 8620ae1

13 files changed

+20
-5
lines changed
 

‎astroid/arguments.py

+2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def infer_argument(
142142
self, funcnode: InferenceResult, name: str, context: InferenceContext
143143
): # noqa: C901
144144
"""Infer a function argument value according to the call context."""
145+
# pylint: disable = too-many-branches
146+
145147
if not isinstance(funcnode, (nodes.FunctionDef, nodes.Lambda)):
146148
raise InferenceError(
147149
f"Can not infer function argument value for non-function node {funcnode!r}.",

‎astroid/brain/brain_builtin_inference.py

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def on_bootstrap():
176176

177177

178178
def _builtin_filter_predicate(node, builtin_name) -> bool:
179+
# pylint: disable = too-many-boolean-expressions
179180
if (
180181
builtin_name == "type"
181182
and node.root().name == "re"

‎astroid/brain/brain_dataclasses.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,12 @@ def _get_previous_field_default(node: nodes.ClassDef, name: str) -> nodes.NodeNG
238238
return None
239239

240240

241-
def _generate_dataclass_init( # pylint: disable=too-many-locals
241+
def _generate_dataclass_init(
242242
node: nodes.ClassDef, assigns: list[nodes.AnnAssign], kw_only_decorated: bool
243243
) -> str:
244244
"""Return an init method for a dataclass given the targets."""
245+
# pylint: disable = too-many-locals, too-many-branches, too-many-statements
246+
245247
params: list[str] = []
246248
kw_only_params: list[str] = []
247249
assignments: list[str] = []

‎astroid/brain/brain_gi.py

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def _gi_build_stub(parent): # noqa: C901
5959
Inspect the passed module recursively and build stubs for functions,
6060
classes, etc.
6161
"""
62+
# pylint: disable = too-many-branches, too-many-statements
63+
6264
classes = {}
6365
functions = {}
6466
constants = {}

‎astroid/brain/brain_namedtuple_enum.py

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def _get_renamed_namedtuple_attributes(field_names):
268268
names = list(field_names)
269269
seen = set()
270270
for i, name in enumerate(field_names):
271+
# pylint: disable = too-many-boolean-expressions
271272
if (
272273
not all(c.isalnum() or c == "_" for c in name)
273274
or keyword.iskeyword(name)

‎astroid/decorators.py

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
137137
raise ValueError(
138138
f"Can't find argument '{arg}' for '{args[0].__class__.__qualname__}'"
139139
) from None
140+
# pylint: disable = too-many-boolean-expressions
140141
if (
141142
# Check kwargs
142143
# - if found, check it's not None

‎astroid/filter_statements.py

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def _filter_stmts(
6767
6868
:returns: The filtered statements.
6969
"""
70+
# pylint: disable = too-many-branches, too-many-statements
71+
7072
# if offset == -1, my actual frame is not the inner frame but its parent
7173
#
7274
# class A(B): pass

‎astroid/nodes/_base_nodes.py

+1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ def _get_binop_flow(
603603
),
604604
]
605605

606+
# pylint: disable = too-many-boolean-expressions
606607
if (
607608
PY310_PLUS
608609
and op == "|"

‎astroid/nodes/node_ng.py

+2
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,8 @@ def repr_tree(
656656
:rtype: str
657657
"""
658658

659+
# pylint: disable = too-many-statements
660+
659661
@_singledispatch
660662
def _repr_tree(node, result, done, cur_indent="", depth=1):
661663
"""Outputs a representation of a non-tuple/list, non-node that's

‎astroid/protocols.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ def starred_assigned_stmts( # noqa: C901
691691
the inference results.
692692
"""
693693

694-
# pylint: disable=too-many-locals,too-many-statements
694+
# pylint: disable = too-many-locals, too-many-statements, too-many-branches
695+
695696
def _determine_starred_iteration_lookups(
696697
starred: nodes.Starred, target: nodes.Tuple, lookups: list[tuple[int, int]]
697698
) -> None:

‎pylintrc

-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ disable=fixme,
9292
missing-docstring,
9393
too-few-public-methods,
9494
too-many-public-methods,
95-
too-many-boolean-expressions,
96-
too-many-branches,
97-
too-many-statements,
9895
# We know about it and we're doing our best to remove it in 2.0 (oups)
9996
cyclic-import,
10097
# Requires major redesign for fixing this (and private

‎tests/test_inference.py

+1
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,7 @@ def randint(maximum):
12621262

12631263
def test_binary_op_or_union_type(self) -> None:
12641264
"""Binary or union is only defined for Python 3.10+."""
1265+
# pylint: disable = too-many-statements
12651266
code = """
12661267
class A: ...
12671268

‎tests/test_nodes_lineno.py

+2
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ def test_end_lineno_const() -> None:
557557
@staticmethod
558558
def test_end_lineno_function() -> None:
559559
"""FunctionDef, AsyncFunctionDef, Decorators, Lambda, Arguments."""
560+
# pylint: disable = too-many-statements
560561
code = textwrap.dedent(
561562
"""
562563
def func( #@
@@ -991,6 +992,7 @@ def test_end_lineno_match() -> None:
991992
"""Match, MatchValue, MatchSingleton, MatchSequence, MatchMapping,
992993
MatchClass, MatchStar, MatchOr, MatchAs.
993994
"""
995+
# pylint: disable = too-many-statements
994996
code = textwrap.dedent(
995997
"""
996998
match x: #@

0 commit comments

Comments
 (0)