I am trying to configure pylint to accept two letter variable names without giving the 'doesn't conform to snake_case naming style' warning.
I've set up the default ~/pylintrc and have tried editing it as follows
- adding
variable-rgx=[a-z_][a-z0-9_]{1-30}$ - adding
variable-rgx=[a-z\_][a-z0-9_]{1-30}$(I have no idea why the backslash is there, but I found it on a random website talking about configuring pylint and thought it worth a shot) - both of the above with and without commenting out
variable-naming-style=snake_case - adding a few of the common 2 letter variables I use to
good-names
This is happening (perhaps unsurprisingly) when I run pylint direct in my terminal or via Vim/Ale. I have closed down and restarted my terminal several times and even rebooted once to try and clear any caching that may be going on and I cannot get this to work.
Strangely, changing max-line-length to 120 works just fine, so I know pylint is actually reading ~/pylintrc. Why does this work and my efforts above have not?
Let's go through your approaches and sub-questions one by one:
There's a typo in the repetition specifier. It needs to be a comma instead of a hyphen. The line below will work as expected:
And that's already the solution. Now let's take a look at the other approaches, too.
This suffers from the typo as above. I have no idea what the backslash is supposed to do, either. It allows variables like
\foo- which are still invalid syntax in Python - yay, I guess?Remember kids, don't put random stuff from random websites into your config.
This is inconsequential as
variable-rgxoverridesvariable-naming-style.This does work in the individual case. It overwrites the (sensible) defaults of
('i', 'j', 'k', 'ex', 'Run', '_')as documented, though.Assuming you want to whitelist
yoandoi, you'd add the following line to yourpylintrc:As far as I know, there's no caching whatsoever involved. Changes are applied instantly. This even holds true when running
pylintfrom an IDE or Vim/ALE as in your case (which is btw what I'm also using). It either works right now or you did something wrong.In general, I've found it very helpful to try
pylintoptions from the command line first and put them inpylintconly when I've confirmed they work. This is made easy by the fact that any command line parameter--foobecomesfooinpylintrc.