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