Closed
Description
Bug description
With the following code
""" An example where pylint gives a wrong suggestion """
max(3, max([5] + [i for i in range(6,10) if i % 2 == 0]))
pylint detects a nested call of max
and suggests to just remove the inner max
. But this leads to a type error:
TypeError: '>' not supported between instances of 'list' and 'int'
Configuration
No response
Command used
pylint a.py
Pylint output
************* Module a
a.py:2:0: W3301: Do not use nested call of 'max'; it's possible to do 'max(3, [5] + [i for i in range(6, 10) if i % 2 == 0])' instead (nested-min-max)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
Expected behavior
At the very least not give a wrong suggestion, but ideally give a right one, like for other instances of this problem recently addressed in #8168 and #8234.
For instance, with
max(3, max([5] + [4]))
we now get the working suggestion to replace it with
max(3, *[5] + [4])
so we could suggest in this case too to add a *
:
max(3, *[5] + [i for i in range(6, 10) if i % 2 == 0])
(In this case, one could of course even be smarter, but this may be too specific.)
Pylint version
pylint 2.17.0
astroid 2.15.0
Python 3.10.10 (main, Mar 5 2023, 22:26:53) [GCC 12.2.1 20230201]
OS / Environment
No response
Additional dependencies
No response