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 diff --git a/tests/test_inference.py b/tests/test_inference.py index 8ddf04bc35..3a2af3aed7 100644 --- a/tests/test_inference.py +++ b/tests/test_inference.py @@ -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: ... diff --git a/tests/test_nodes_lineno.py b/tests/test_nodes_lineno.py index c8a8839e21..875d21d565 100644 --- a/tests/test_nodes_lineno.py +++ b/tests/test_nodes_lineno.py @@ -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( #@ @@ -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: #@