Path 1: 2 calls (1.0)

None (2)

('Commands',) (2)

KeyError (2)

1def generate_config(
2        self, stream: TextIO | None = None, skipsections: tuple[str, ...] = ()
3    ) -> None:  # pragma: no cover
4        """DEPRECATED: Write a configuration file according to the current configuration
5        into the given stream or stdout.
6        """
7        warnings.warn(
8            "generate_config has been deprecated. It will be removed in pylint 3.0.",
9            DeprecationWarning,
10            stacklevel=2,
11        )
12        options_by_section = {}
13        sections = []
14        for group in sorted(
15            self._arg_parser._action_groups,
16            key=lambda x: (x.title != "Main", x.title),
17        ):
18            group_name = group.title
19            assert group_name
20            if group_name in skipsections:
21                continue
22
23            options = []
24            option_actions = [
25                i
26                for i in group._group_actions
27                if not isinstance(i, argparse._SubParsersAction)
28            ]
29            for opt in sorted(option_actions, key=lambda x: x.option_strings[0][2:]):
30                if "--help" in opt.option_strings:
31                    continue
32
33                optname = opt.option_strings[0][2:]
34
35                try:
36                    optdict = self._option_dicts[optname]
37                except KeyError:
38                    continue
39
40                options.append(
41                    (
42                        optname,
43                        optdict,
44                        getattr(self.config, optname.replace("-", "_")),
45                    )
46                )
47
48                options = [
49                    (n, d, v) for (n, d, v) in options if not d.get("deprecated")
50                ]
51
52            if options:
53                sections.append(group_name)
54                options_by_section[group_name] = options
55        stream = stream or sys.stdout
56        printed = False
57        for section in sections:
58            if printed:
59                print("\n", file=stream)
60            with warnings.catch_warnings():
61                warnings.filterwarnings("ignore", category=DeprecationWarning)
62                utils.format_section(
63                    stream, section.upper(), sorted(options_by_section[section])
64                )
65            printed = True