Skip to content

[consider-using-any-or-all] No suggestion when the loop condition already contain any / all or is 'large'Β #10052

@Pierre-Sassoulas

Description

@Pierre-Sassoulas

Bug description

See pytest-dev/pytest#12924

        for mark in matches:  # pylint: disable=consider-using-any-or-all
            if all(mark.kwargs.get(k, NOT_SET) == v for k, v in kwargs.items()):
                return True
        return False

Using any would make a really big one liner that is worse than the original loop.

Command used

pylint a.py

Pylint output

src/_pytest/mark/__init__.py:246:8: C0501: `for` loop could be `any(all((mark.kwargs.get(k, NOT_SET) == v for (k, v) in kwargs.items())) for mark in matches)` (consider-using-any-or-all)

Expected behavior

No suggestion when the result would be too big.

Pylint version

pylint 3.3.1
astroid 3.3.5
Python 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions