Method: pylint.checkers.base.name_checker.checker.NameChecker._raise_name_warning
Calls: 1122, Exceptions: 0, Paths: 3Back
Path 1: 1108 calls (0.99)
None (1108)
AssignName (891) ClassDef (82) FunctionDef (74) Module (25) AssignAttr (24) Global (9) Unknown (3)
'variable' (308) 'argument' (271) 'const' (270) 'class' (91) 'function' (40) 'attr' (32) 'method' (29) 'module' (25) 'class_const' (23) 'typevar' (18)...
'x' (160) 'a' (115) 'y' (83) 'b' (82) 'c' (57) 'z' (53) 'result' (31) 'A' (30) 'value' (25) 'd' (23)
Confidence (1108)
'invalid-name' (1108)
1def _raise_name_warning(
2 self,
3 prevalent_group: str | None,
4 node: nodes.NodeNG,
5 node_type: str,
6 name: str,
7 confidence: interfaces.Confidence,
8 warning: str = "invalid-name",
9 ) -> None:
10 type_label = constants.HUMAN_READABLE_TYPES[node_type]
11 hint = self._name_hints[node_type]
12 if prevalent_group:
13 # This happens in the multi naming match case. The expected
14 # prevalent group needs to be spelled out to make the message
15 # correct.
16 hint = f"the `{prevalent_group}` group in the {hint}"
17 if self.linter.config.include_naming_hint:
18 hint += f" ({self._name_regexps[node_type].pattern!r} pattern)"
19 args = (
20 (type_label.capitalize(), name, hint)
21 if warning == "invalid-name"
22 else (type_label.capitalize(), name)
23 )
24
25 self.add_message(warning, node=node, args=args, confidence=confidence)
26 self.linter.stats.increase_bad_name(node_type, 1)
Path 2: 9 calls (0.01)
None (9)
ClassDef (4) AssignName (3) FunctionDef (2)
'class' (4) 'const' (3) 'function' (2)
'SOME_CONSTANT' (2) 'MyClass' (2) 'say_hello' (1) 'snake_case_bad_SOME_CONSTANT' (1) 'sayHello' (1) 'FooEnum' (1) 'Bar' (1)
Confidence (9)
'invalid-name' (9)
1def _raise_name_warning(
2 self,
3 prevalent_group: str | None,
4 node: nodes.NodeNG,
5 node_type: str,
6 name: str,
7 confidence: interfaces.Confidence,
8 warning: str = "invalid-name",
9 ) -> None:
10 type_label = constants.HUMAN_READABLE_TYPES[node_type]
11 hint = self._name_hints[node_type]
12 if prevalent_group:
13 # This happens in the multi naming match case. The expected
14 # prevalent group needs to be spelled out to make the message
15 # correct.
16 hint = f"the `{prevalent_group}` group in the {hint}"
17 if self.linter.config.include_naming_hint:
18 hint += f" ({self._name_regexps[node_type].pattern!r} pattern)"
19 args = (
20 (type_label.capitalize(), name, hint)
21 if warning == "invalid-name"
22 else (type_label.capitalize(), name)
23 )
24
25 self.add_message(warning, node=node, args=args, confidence=confidence)
26 self.linter.stats.increase_bad_name(node_type, 1)
Path 3: 5 calls (0.0)
'down' (4) 'UP' (1)
FunctionDef (3) ClassDef (2)
'function' (3) 'class' (2)
'UPPER' (2) 'classb' (1) 'CLASSC' (1) 'FUNC' (1)
Confidence (5)
'invalid-name' (5)
1def _raise_name_warning(
2 self,
3 prevalent_group: str | None,
4 node: nodes.NodeNG,
5 node_type: str,
6 name: str,
7 confidence: interfaces.Confidence,
8 warning: str = "invalid-name",
9 ) -> None:
10 type_label = constants.HUMAN_READABLE_TYPES[node_type]
11 hint = self._name_hints[node_type]
12 if prevalent_group:
13 # This happens in the multi naming match case. The expected
14 # prevalent group needs to be spelled out to make the message
15 # correct.
16 hint = f"the `{prevalent_group}` group in the {hint}"
17 if self.linter.config.include_naming_hint:
18 hint += f" ({self._name_regexps[node_type].pattern!r} pattern)"
19 args = (
20 (type_label.capitalize(), name, hint)
21 if warning == "invalid-name"
22 else (type_label.capitalize(), name)
23 )
24
25 self.add_message(warning, node=node, args=args, confidence=confidence)
26 self.linter.stats.increase_bad_name(node_type, 1)