Skip to content

Enable design complexity checks #2591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions astroid/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def infer_argument(
self, funcnode: InferenceResult, name: str, context: InferenceContext
): # noqa: C901
"""Infer a function argument value according to the call context."""
# pylint: disable = too-many-branches

if not isinstance(funcnode, (nodes.FunctionDef, nodes.Lambda)):
raise InferenceError(
f"Can not infer function argument value for non-function node {funcnode!r}.",
Expand Down
1 change: 1 addition & 0 deletions astroid/brain/brain_builtin_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def on_bootstrap():


def _builtin_filter_predicate(node, builtin_name) -> bool:
# pylint: disable = too-many-boolean-expressions
if (
builtin_name == "type"
and node.root().name == "re"
Expand Down
4 changes: 3 additions & 1 deletion astroid/brain/brain_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,12 @@ def _get_previous_field_default(node: nodes.ClassDef, name: str) -> nodes.NodeNG
return None


def _generate_dataclass_init( # pylint: disable=too-many-locals
def _generate_dataclass_init(
node: nodes.ClassDef, assigns: list[nodes.AnnAssign], kw_only_decorated: bool
) -> str:
"""Return an init method for a dataclass given the targets."""
# pylint: disable = too-many-locals, too-many-branches, too-many-statements

params: list[str] = []
kw_only_params: list[str] = []
assignments: list[str] = []
Expand Down
2 changes: 2 additions & 0 deletions astroid/brain/brain_gi.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def _gi_build_stub(parent): # noqa: C901
Inspect the passed module recursively and build stubs for functions,
classes, etc.
"""
# pylint: disable = too-many-branches, too-many-statements

classes = {}
functions = {}
constants = {}
Expand Down
1 change: 1 addition & 0 deletions astroid/brain/brain_namedtuple_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def _get_renamed_namedtuple_attributes(field_names):
names = list(field_names)
seen = set()
for i, name in enumerate(field_names):
# pylint: disable = too-many-boolean-expressions
if (
not all(c.isalnum() or c == "_" for c in name)
or keyword.iskeyword(name)
Expand Down
1 change: 1 addition & 0 deletions astroid/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
raise ValueError(
f"Can't find argument '{arg}' for '{args[0].__class__.__qualname__}'"
) from None
# pylint: disable = too-many-boolean-expressions
if (
# Check kwargs
# - if found, check it's not None
Expand Down
2 changes: 2 additions & 0 deletions astroid/filter_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def _filter_stmts(

:returns: The filtered statements.
"""
# pylint: disable = too-many-branches, too-many-statements

# if offset == -1, my actual frame is not the inner frame but its parent
#
# class A(B): pass
Expand Down
1 change: 1 addition & 0 deletions astroid/nodes/_base_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ def _get_binop_flow(
),
]

# pylint: disable = too-many-boolean-expressions
if (
PY310_PLUS
and op == "|"
Expand Down
2 changes: 2 additions & 0 deletions astroid/nodes/node_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ def repr_tree(
:rtype: str
"""

# pylint: disable = too-many-statements

@_singledispatch
def _repr_tree(node, result, done, cur_indent="", depth=1):
"""Outputs a representation of a non-tuple/list, non-node that's
Expand Down
3 changes: 2 additions & 1 deletion astroid/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@ def starred_assigned_stmts( # noqa: C901
the inference results.
"""

# pylint: disable=too-many-locals,too-many-statements
# pylint: disable = too-many-locals, too-many-statements, too-many-branches

def _determine_starred_iteration_lookups(
starred: nodes.Starred, target: nodes.Tuple, lookups: list[tuple[int, int]]
) -> None:
Expand Down
3 changes: 0 additions & 3 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ disable=fixme,
missing-docstring,
too-few-public-methods,
too-many-public-methods,
too-many-boolean-expressions,
too-many-branches,
too-many-statements,
# We know about it and we're doing our best to remove it in 2.0 (oups)
cyclic-import,
# Requires major redesign for fixing this (and private
Expand Down
1 change: 1 addition & 0 deletions tests/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@ def randint(maximum):

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

Expand Down
2 changes: 2 additions & 0 deletions tests/test_nodes_lineno.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ def test_end_lineno_const() -> None:
@staticmethod
def test_end_lineno_function() -> None:
"""FunctionDef, AsyncFunctionDef, Decorators, Lambda, Arguments."""
# pylint: disable = too-many-statements
code = textwrap.dedent(
"""
def func( #@
Expand Down Expand Up @@ -991,6 +992,7 @@ def test_end_lineno_match() -> None:
"""Match, MatchValue, MatchSingleton, MatchSequence, MatchMapping,
MatchClass, MatchStar, MatchOr, MatchAs.
"""
# pylint: disable = too-many-statements
code = textwrap.dedent(
"""
match x: #@
Expand Down
Loading