From 3e7db7c7bb55e743dfde59b4b76ffdb25feef55f Mon Sep 17 00:00:00 2001 From: Nick Drozd Date: Mon, 30 Sep 2024 11:34:11 -0400 Subject: [PATCH] Enable design complexity checks --- astroid/arguments.py | 2 ++ astroid/brain/brain_builtin_inference.py | 1 + astroid/brain/brain_dataclasses.py | 4 +++- astroid/brain/brain_gi.py | 2 ++ astroid/brain/brain_namedtuple_enum.py | 1 + astroid/decorators.py | 1 + astroid/filter_statements.py | 2 ++ astroid/nodes/_base_nodes.py | 1 + astroid/nodes/node_ng.py | 2 ++ astroid/protocols.py | 3 ++- pylintrc | 3 --- 11 files changed, 17 insertions(+), 5 deletions(-) diff --git a/astroid/arguments.py b/astroid/arguments.py index 29336cf8f1..3781889b7c 100644 --- a/astroid/arguments.py +++ b/astroid/arguments.py @@ -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}.", diff --git a/astroid/brain/brain_builtin_inference.py b/astroid/brain/brain_builtin_inference.py index c60510d0b9..821261933b 100644 --- a/astroid/brain/brain_builtin_inference.py +++ b/astroid/brain/brain_builtin_inference.py @@ -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" diff --git a/astroid/brain/brain_dataclasses.py b/astroid/brain/brain_dataclasses.py index 845295bf9b..92d983e2b0 100644 --- a/astroid/brain/brain_dataclasses.py +++ b/astroid/brain/brain_dataclasses.py @@ -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] = [] diff --git a/astroid/brain/brain_gi.py b/astroid/brain/brain_gi.py index 4ebbdde2ab..fa600775dc 100644 --- a/astroid/brain/brain_gi.py +++ b/astroid/brain/brain_gi.py @@ -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 = {} diff --git a/astroid/brain/brain_namedtuple_enum.py b/astroid/brain/brain_namedtuple_enum.py index 72a07c1187..b39d177b10 100644 --- a/astroid/brain/brain_namedtuple_enum.py +++ b/astroid/brain/brain_namedtuple_enum.py @@ -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) diff --git a/astroid/decorators.py b/astroid/decorators.py index 6c8b1bac32..cd0f5a7961 100644 --- a/astroid/decorators.py +++ b/astroid/decorators.py @@ -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 diff --git a/astroid/filter_statements.py b/astroid/filter_statements.py index 627e68edc9..a48b6e7d9f 100644 --- a/astroid/filter_statements.py +++ b/astroid/filter_statements.py @@ -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 diff --git a/astroid/nodes/_base_nodes.py b/astroid/nodes/_base_nodes.py index 2d210f17af..65b703d042 100644 --- a/astroid/nodes/_base_nodes.py +++ b/astroid/nodes/_base_nodes.py @@ -603,6 +603,7 @@ def _get_binop_flow( ), ] + # pylint: disable = too-many-boolean-expressions if ( PY310_PLUS and op == "|" diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 6d149e3840..99120bb65f 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -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 diff --git a/astroid/protocols.py b/astroid/protocols.py index bacb786a99..0bac32a29a 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -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: diff --git a/pylintrc b/pylintrc index 12a01eb568..64218020ce 100644 --- a/pylintrc +++ b/pylintrc @@ -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