Path 1: 995 calls (0.99)

tuple (995)

1def _create_naming_rules(self) -> tuple[dict[str, Pattern[str]], dict[str, str]]:
2        regexps: dict[str, Pattern[str]] = {}
3        hints: dict[str, str] = {}
4
5        for name_type in KNOWN_NAME_TYPES:
6            if name_type in KNOWN_NAME_TYPES_WITH_STYLE:
7                naming_style_name = getattr(
8                    self.linter.config, f"{name_type}_naming_style"
9                )
10                regexps[name_type] = NAMING_STYLES[naming_style_name].get_regex(
11                    name_type
12                )
13            else:
14                naming_style_name = "predefined"
15                regexps[name_type] = DEFAULT_PATTERNS[name_type]
16
17            custom_regex_setting_name = f"{name_type}_rgx"
18            custom_regex = getattr(self.linter.config, custom_regex_setting_name, None)
19            if custom_regex is not None:
20                regexps[name_type] = custom_regex
21
22            if custom_regex is not None:
23                hints[name_type] = f"{custom_regex.pattern!r} pattern"
24            else:
25                hints[name_type] = f"{naming_style_name} naming style"
26
27        return regexps, hints
            

Path 2: 15 calls (0.01)

tuple (15)

1def _create_naming_rules(self) -> tuple[dict[str, Pattern[str]], dict[str, str]]:
2        regexps: dict[str, Pattern[str]] = {}
3        hints: dict[str, str] = {}
4
5        for name_type in KNOWN_NAME_TYPES:
6            if name_type in KNOWN_NAME_TYPES_WITH_STYLE:
7                naming_style_name = getattr(
8                    self.linter.config, f"{name_type}_naming_style"
9                )
10                regexps[name_type] = NAMING_STYLES[naming_style_name].get_regex(
11                    name_type
12                )
13            else:
14                naming_style_name = "predefined"
15                regexps[name_type] = DEFAULT_PATTERNS[name_type]
16
17            custom_regex_setting_name = f"{name_type}_rgx"
18            custom_regex = getattr(self.linter.config, custom_regex_setting_name, None)
19            if custom_regex is not None:
20                regexps[name_type] = custom_regex
21
22            if custom_regex is not None:
23                hints[name_type] = f"{custom_regex.pattern!r} pattern"
24            else:
25                hints[name_type] = f"{naming_style_name} naming style"
26
27        return regexps, hints