I keep getting C0103
warnings from pylint in Visual Studio, because I am trying to use 2-character variables names like hp
and gp
. The warning is described here: link.
The convention is described as [a-z_][a-z0-9_]{2,30}$
for variable-rgx
. I don't actually know how to read this regex thing or what it means, but it looks like the {2,30}
part describes the possible length range, so (correct me if I'm wrong) why isn't character length two allowed? Or would there be some other reason why a variable name such as gp
would give an error?
When this question is asked, people often link to PEP-8, but I don't remember reading that variable names specifically must have a minimum length of 3 characters. Anyway, I get this is probably bad form, but I don't want to follow this convention. In the context of my program it is abundantly clear what 2-character variable names such as gp
and hp
would mean, and this feels like way to much of a restriction on coding style.
So in any case, what I want to do is specifically override this warning. I don't want to just disable C0103
. I would instead prefer to change this within my text editor (Visual Studio Code), like in the setting where for example you can change pylint
args with "python.linting.pylintArgs": [...]
. So what would the correct change be if I wanted to override the convention to allow 2-character variable names? Or would I have to write a new lintrc file (not sure how to do that, and I would prefer a lighter solution where I only change it in VSCode).
Open user settings (Ctrl + ,), input in the search bar pylintArgs
, hover the mouse over the "python.linting.pylintArgs": []
and select edit
. It will be copied to either User Settings
or Workspace Settings
on the right side. There input the required parameter:
"python.linting.pylintArgs": [
"--variable-rgx=[a-z_][a-z0-9_]{1,30}$"
]