Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable invalid name arguments pylint

Tags:

python

pylint

I have code like this:

def func(df):
    return df.column[0]

I am running pylint and it gives me this message all the time because it flags df as an invalid name despite it's convention.

C:210, 9: Invalid variable name "df" (invalid-name)

Where 210 refers to the row number (not the message code)

Pylint seems to say I can exclude messages by id type but:

  1. It doesn't seem to list the message id, just the row and column numbers
  2. I don't see where I would exclude messages for a specific variable name but not warnings for other variable names.
like image 607
Chris Avatar asked Jun 13 '16 21:06

Chris


People also ask

How do I get rid of invalid name Pylint?

How do I get rid of invalid name pylint? Create an empty Python file called run-tests.py. At the top of the file, add # pylint: disable=invalid-name so that pylint won't complain about the module name.

How do you ignore 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.


1 Answers

In your pylintrc file you can define a good-names variable with a comma seperated list of acceptable names that would otherwise fail the regex.

# Good variable names which should always be accepted, separated by a comma
good-names=i,j,df

If you do not already have a pylintrc file for your project you can generate a template to start with by running:

pylint --generate-rcfile > pylintrc
like image 69
Kara Avatar answered Sep 18 '22 20:09

Kara