assign list.sort() instead of sorted(list) #5722
Labels
False Negative 🦋
No message is emitted but something is wrong with the code
Help wanted 🙏
Outside help would be appreciated, good for new contributors
Milestone
Current problem
when you use the
sort()
method on a list object, it modifies the list and returns None.A common mistake is to assign the return value of this assignment (i.e. None) to a variable thinking you assigned the sorted list instead.
Results with:
None in
A
and [1,2,3] inlst
.Desired solution
The checker should raise the WARNING message:
“A sort method of
list
object is assigned to a variable and equals None, consider using thesorted()
function instead”.Additional context
When i run pylint with all extensions on the example above I don't get any message.
But PyCharm's linter has a message for it so I am not sure if it was already implemented.
If not I could write it.
The text was updated successfully, but these errors were encountered: