Skip to content

Commit 32c6f3a

Browse files
DanielNoordCarliJoy
authored andcommitted
Move HUMAN_READABLE_TYPES to constants (pylint-dev#5642)
Ref pylint-dev#5311 Co-authored-by: Carli* Freudenberg <[email protected]>
1 parent ee239d3 commit 32c6f3a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

pylint/checkers/base.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
import astroid
7979
from astroid import nodes
8080

81-
from pylint import checkers, interfaces
81+
from pylint import checkers, constants, interfaces
8282
from pylint import utils as lint_utils
8383
from pylint.checkers import utils
8484
from pylint.checkers.utils import (
@@ -1672,20 +1672,6 @@ def visit_for(self, node: nodes.For) -> None:
16721672
"inlinevar",
16731673
}
16741674

1675-
HUMAN_READABLE_TYPES = {
1676-
"module": "module",
1677-
"const": "constant",
1678-
"class": "class",
1679-
"function": "function",
1680-
"method": "method",
1681-
"attr": "attribute",
1682-
"argument": "argument",
1683-
"variable": "variable",
1684-
"class_attribute": "class attribute",
1685-
"class_const": "class constant",
1686-
"inlinevar": "inline iteration",
1687-
}
1688-
16891675
DEFAULT_NAMING_STYLES = {
16901676
"module": "snake_case",
16911677
"const": "UPPER_CASE",
@@ -1704,7 +1690,7 @@ def visit_for(self, node: nodes.For) -> None:
17041690
def _create_naming_options():
17051691
name_options = []
17061692
for name_type in sorted(KNOWN_NAME_TYPES):
1707-
human_readable_name = HUMAN_READABLE_TYPES[name_type]
1693+
human_readable_name = constants.HUMAN_READABLE_TYPES[name_type]
17081694
default_style = DEFAULT_NAMING_STYLES[name_type]
17091695
name_type = name_type.replace("_", "-")
17101696
name_options.append(
@@ -2025,7 +2011,7 @@ def _raise_name_warning(
20252011
confidence,
20262012
warning: str = "invalid-name",
20272013
) -> None:
2028-
type_label = HUMAN_READABLE_TYPES[node_type]
2014+
type_label = constants.HUMAN_READABLE_TYPES[node_type]
20292015
hint = self._name_hints[node_type]
20302016
if prevalent_group:
20312017
# This happens in the multi naming match case. The expected

pylint/constants.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,17 @@ class WarningScope:
5555
full_version = f"""pylint {__version__}
5656
astroid {astroid.__version__}
5757
Python {sys.version}"""
58+
59+
HUMAN_READABLE_TYPES = {
60+
"module": "module",
61+
"const": "constant",
62+
"class": "class",
63+
"function": "function",
64+
"method": "method",
65+
"attr": "attribute",
66+
"argument": "argument",
67+
"variable": "variable",
68+
"class_attribute": "class attribute",
69+
"class_const": "class constant",
70+
"inlinevar": "inline iteration",
71+
}

0 commit comments

Comments
 (0)