Skip to content

Commit

Permalink
Enable design complexity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Sep 30, 2024
1 parent 62c5bad commit 3e7db7c
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 5 deletions.
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

0 comments on commit 3e7db7c

Please sign in to comment.