Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pylint variable name doesn't conform to snake_case naming style

Tags:

I have multiple warnings from pylint like that: '''Variable name "df" doesn't conform to snake_case naming style''' As I could understand, it happens because of variable name length less than 3 symbols. however I would like to use variables like df, i, x etc.

So, I require to add several variable names to linting exceptions. I tried to add that names to good-names section of pylintrc file in my project directory, where manage.py is located: pylintrc: '''# Good variable names which should always be accepted, separated by a comma. good-names=i, j, k, ex, Run, df, l, l1, l2, l3''' It didn't helped, I still received warnings about variable names style. I will highly appreciate if somebody could help with ideas.

like image 531
Alexander Avatar asked Oct 31 '20 14:10

Alexander


People also ask

What is Snake_case naming style?

Snake case (stylized as snake_case) refers to the style of writing in which each space is replaced by an underscore (_) character, and the first letter of each word is written in lowercase. It is a commonly used naming convention in computing, for example for variable and subroutine names, and for filenames.

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. Pylint complains anyway.

What is Python Snakecase?

Python, by contrast, recommends snake case, whereby words are instead separated by underscores ( _ ), with all letters in lowercase. For instance, those same variables would be called name , first_name , and preferred_first_name , respectively, in Python.


1 Answers

In the .pylintrc file, the good-names=... line should be prefaced by a [BASIC] keyword, i.e.:

[BASIC]

# Good variable names which should always be accepted, separated by a comma.
good-names=i, j, k, ex, Run, df, l, l1, l2, l3
like image 157
fpavogt Avatar answered Sep 18 '22 22:09

fpavogt