Skip to content

consider-using-generator error message ignores default arguments #8563

@ioah86

Description

@ioah86

Bug description

The built-in min function of python has multiple ways of calling it, as described in the documentation.

While this

min([i for i in range(len(line)) if line[i] not in whitespaces])

does correctly trigger the pylint error, I am also getting the error for this

min([i for i in range(len(line)) if line[i] not in whitespaces], default=0)

There is no other way for no.2, and I think that the linter just does not take this way of calling min into account.

Configuration

No response

Command used

pylint src/hidden_type/util.py

Pylint output

************* Module src.hidden_type.util
src/hidden_type/util.py:523:14: R1728: Consider using a generator instead 'min(i for i in range(len(line)) if line[i] not in whitespaces)' (consider-using-generator)

------------------------------------------------------------------
Your code has been rated at 9.96/10 (previous run: 9.92/10, +0.04)

Expected behavior

No error.

Pylint version

pylint 2.17.2
astroid 2.15.2
Python 3.10.10 (main, Mar  5 2023, 22:26:53) [GCC 12.2.1 20230201]

OS / Environment

Linux my-x1-yoga 6.1.23-1-lts #1 SMP PREEMPT_DYNAMIC Thu, 06 Apr 2023 10:56:12 +0000 x86_64 GNU/Linux
(Arch Linux)

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Documentation 📗Minor 💅Polishing pylint is always niceNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions