Skip to content

Commit 00321dc

Browse files
authored
Update formatting for NamingStyles (#6294)
1 parent a10ff70 commit 00321dc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pylint/checkers/base/name_checker/naming_style.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ def get_regex(cls, name_type):
4141
class SnakeCaseStyle(NamingStyle):
4242
"""Regex rules for snake_case naming style."""
4343

44-
CLASS_NAME_RGX = COMP_VAR_RGX = re.compile(r"[^\W\dA-Z][^\WA-Z]+$")
44+
CLASS_NAME_RGX = re.compile(r"[^\W\dA-Z][^\WA-Z]+$")
4545
MOD_NAME_RGX = re.compile(r"[^\W\dA-Z][^\WA-Z]*$")
4646
CONST_NAME_RGX = re.compile(r"([^\W\dA-Z][^\WA-Z]*|__.*__)$")
47+
COMP_VAR_RGX = CLASS_NAME_RGX
4748
DEFAULT_NAME_RGX = re.compile(
4849
r"([^\W\dA-Z][^\WA-Z]{2,}|_[^\WA-Z]*|__[^\WA-Z\d_][^\WA-Z]+__)$"
4950
)
@@ -54,26 +55,31 @@ class CamelCaseStyle(NamingStyle):
5455
"""Regex rules for camelCase naming style."""
5556

5657
CLASS_NAME_RGX = re.compile(r"[^\W\dA-Z][^\W_]+$")
57-
MOD_NAME_RGX = COMP_VAR_RGX = re.compile(r"[^\W\dA-Z][^\W_]*$")
58+
MOD_NAME_RGX = re.compile(r"[^\W\dA-Z][^\W_]*$")
5859
CONST_NAME_RGX = re.compile(r"([^\W\dA-Z][^\W_]*|__.*__)$")
60+
COMP_VAR_RGX = MOD_NAME_RGX
5961
DEFAULT_NAME_RGX = re.compile(r"([^\W\dA-Z][^\W_]{2,}|__[^\W\dA-Z_]\w+__)$")
6062
CLASS_ATTRIBUTE_RGX = re.compile(r"([^\W\dA-Z][^\W_]{2,}|__.*__)$")
6163

6264

6365
class PascalCaseStyle(NamingStyle):
6466
"""Regex rules for PascalCase naming style."""
6567

66-
CLASS_NAME_RGX = MOD_NAME_RGX = COMP_VAR_RGX = re.compile(r"[^\W\da-z][^\W_]+$")
68+
CLASS_NAME_RGX = re.compile(r"[^\W\da-z][^\W_]+$")
69+
MOD_NAME_RGX = CLASS_NAME_RGX
6770
CONST_NAME_RGX = re.compile(r"([^\W\da-z][^\W_]*|__.*__)$")
71+
COMP_VAR_RGX = CLASS_NAME_RGX
6872
DEFAULT_NAME_RGX = re.compile(r"([^\W\da-z][^\W_]{2,}|__[^\W\dA-Z_]\w+__)$")
6973
CLASS_ATTRIBUTE_RGX = re.compile(r"[^\W\da-z][^\W_]{2,}$")
7074

7175

7276
class UpperCaseStyle(NamingStyle):
7377
"""Regex rules for UPPER_CASE naming style."""
7478

75-
CLASS_NAME_RGX = MOD_NAME_RGX = COMP_VAR_RGX = re.compile(r"[^\W\da-z][^\Wa-z]+$")
79+
CLASS_NAME_RGX = re.compile(r"[^\W\da-z][^\Wa-z]+$")
80+
MOD_NAME_RGX = CLASS_NAME_RGX
7681
CONST_NAME_RGX = re.compile(r"([^\W\da-z][^\Wa-z]*|__.*__)$")
82+
COMP_VAR_RGX = CLASS_NAME_RGX
7783
DEFAULT_NAME_RGX = re.compile(r"([^\W\da-z][^\Wa-z]{2,}|__[^\W\dA-Z_]\w+__)$")
7884
CLASS_ATTRIBUTE_RGX = re.compile(r"[^\W\da-z][^\Wa-z]{2,}$")
7985

0 commit comments

Comments
 (0)