I have a line like this:
filter(lambda x: x == 1, [1, 1, 2])
Pylint is showing a warning:
W: 3: Used builtin function 'filter'
Why is that? is a list comprehension the recommended method?
Of course I can rewrite this like this:
[x for x in [1, 1, 2] if x == 1]
And I get no warnings, but I was wondering if there's a PEP for this?
This may be done by adding # pylint: disable=some-message,another-one at the desired block level or at the end of the desired line of code.
you can ignore it by adding a comment in the format # pylint: disable=[problem-code] at the end of the line where [problem-code] is the value inside pylint(...) in the pylint message – for example, abstract-class-instantiated for the problem report listed above.
OUTPUT Using the default text output, the message format is : MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE There are 5 kind of message types : * (C) convention, for programming standard violation * (R) refactor, for bad code smell * (W) warning, for python specific problems * (E) error, for probable bugs in the code * (F) ...
The solution was to include --disable=file-ignored in the Pylint command options.
Pylint often chatters on about stuff it shouldn't. You can disable the warning in a .pylintrc file.
This page http://pylint-messages.wikidot.com/messages:w0141 indicates the problem is that filter and map have been superseded by list comprehensions.
A line like this in your pylintrc file will quiet the warning:
disable=W0141
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With