Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Pylint like built-in functions?

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?

like image 264
igorgue Avatar asked Aug 25 '10 18:08

igorgue


People also ask

How do I ignore Pylint errors?

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.

How do you bypass Pylint?

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.

What is C in Pylint?

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) ...

How do I know if a Pylint is ignoring a file?

The solution was to include --disable=file-ignored in the Pylint command options.


1 Answers

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 
like image 177
Ned Batchelder Avatar answered Sep 21 '22 19:09

Ned Batchelder