4812N/APylint recognizes a number of different name types internally. With a
4812N/Afew exceptions, the type of the name is governed by the location the
4812N/Aassignment to a name is found in, and not the type of object assigned.
4812N/A Module and package names, same as the file names.
4812N/A Module-level constants, any variable defined at module level that
4812N/A is not bound to a class object.
4812N/A Names in "class" statements, as well as names bound to class
4812N/A Functions, toplevel or nested in functions or methods.
4812N/A Methods, functions defined in class bodies. Includes static and
4812N/A Attributes created on class instances inside methods.
4812N/A Arguments to any function type, including lambdas.
4812N/A Local variables in function scopes.
4812N/A Attributes defined in class bodies.
4812N/A Loop variables in list comprehensions and generator expressions.
4812N/AFor each naming style, a separate regular expression matching valid
4812N/Anames of this type can be defined. By default, the regular expressions
4812N/ARegular expressions for the names are anchored at the beginning, any
4812N/Aanchor for the end must be supplied explicitly. Any name not matching
4812N/Athe regular expression will lead to an instance of "invalid-name".
4812N/A Default value: "[a-z_][a-z0-9_]{2,30}$"
4812N/A Default value: "[a-z_][a-z0-9_]{2,30}$"
4812N/A Default value: "'[A-Z_][a-zA-Z0-9]+$"
4812N/A Default value: "[a-z_][a-z0-9_]{2,30}$"
4812N/A Default value: "[a-z_][a-z0-9_]{2,30}$"
4812N/A Default value: "[a-z_][a-z0-9_]{2,30}$"
4812N/A Default value: "[a-z_][a-z0-9_]{2,30}$"
4812N/A Default value: "[a-z_][a-z0-9_]{2,30}$"
4812N/A--class-attribute-rgx=<regex>
4812N/A Default value: "([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$"
4812N/A Default value: "[A-Za-z_][A-Za-z0-9_]*$"
4812N/ALarge code bases that have been worked on for multiple years often
4812N/Aexhibit an evolution in style as well. In some cases, modules can be
4812N/Ain the same package, but still have different naming style based on
4812N/Athe stratum they belong to. However, intra-module consistency should
4812N/Astill be required, to make changes inside a single file easier. For
4812N/Athis case, Pylint supports regular expression with several named
4812N/ARather than emitting name warnings immediately, Pylint will determine
4812N/Athe prevalent naming style inside each module and enforce it on all
4812N/AConsider the following (simplified) example:
4812N/A pylint --function-rgx='(?:(?P<snake>[a-z_]+)|(?P<camel>_?[A-Z]+))$'
sample.py 4812N/AThe regular expression defines two naming styles, "snake" for snake-
4812N/Acase names, and "camel" for camel-case names.
4812N/Aand enforce the match of named group "snake" for the remaining names
4812N/A def more_valid_snake_case(arg):
4812N/ABecause of this, the name on line 4 will trigger an "invalid-name"
4812N/Awarning, even though the name matches the given regex.
4812N/AMatches named "exempt" or "ignore" can be used for non-tainting names,
4812N/Ato prevent built-in or interface-dictated names to trigger certain
4812N/A--name-group=<name1:name2:...,...>
4812N/A Format: comma-separated groups of colon-separated names.
4812N/A This option can be used to combine name styles. For example,
4812N/A "function:method" enforces that functions and methods use the same
4812N/A style, and a style triggered by either name type carries over to
4812N/A the other. This requires that the regular expression for the
4812N/A combined name types use the same group names.
4812N/A Include a hint for the correct name format with every "invalid-
4812N/A Name hints default to the regular expression, but can be separately
4812N/A configured with the "--<name-type>-hint" options.