I'm coming from a world where we program mostly in C++ and our minimal Python code often uses a mix of Pythonic methods and C++ best practices.
As such I'd like to create some custom regexes for variable naming. Example:
^([a-z]+)(?:([A-Z]{1})([a-z]+))+$|^[A-Z][a-z]+(?:[A-Z][a-z]+)*$
matches both camelCase
and PascalCase
. Sometimes our methods, classes, filenames are PascalCase
and sometimes they are camelCase
. The above regex matches both.
Is it possible to create a pascalCase_or_CamelCase
variable inside of always using the above? There are more examples like this but if one variable can be created based on the above I can follow suit for all the other overrides we need.
Creating a variable in the pylintrc is not possible, the simpler thing to do is to copy paste your regex in each regex option.
You could make a pylint plugin defining your own predefined style, and then it's in python so you can make as many variable as you want. See https://pylint.readthedocs.io/en/stable/user_guide/messages/convention/invalid-name.html#predefined-naming-styles and https://github.com/pylint-dev/pylint/blob/main/pylint/checkers/base/name_checker/naming_style.py
Notice that there is a lot of documentation around invalid-name in the first provided link, creating a custom plugin should not be required.