diff --git a/doc/whatsnew/fragments/7655.other b/doc/whatsnew/fragments/7655.other new file mode 100644 index 0000000000..9024fe38e8 --- /dev/null +++ b/doc/whatsnew/fragments/7655.other @@ -0,0 +1,3 @@ +Sort ``--generated-rcfile`` output. + +Refs #7655 diff --git a/pylint/config/arguments_manager.py b/pylint/config/arguments_manager.py index eda1a583d4..40058071cc 100644 --- a/pylint/config/arguments_manager.py +++ b/pylint/config/arguments_manager.py @@ -437,7 +437,10 @@ def generate_config( ) options_by_section = {} sections = [] - for group in self._arg_parser._action_groups: + for group in sorted( + self._arg_parser._action_groups, + key=lambda x: (x.title != "Main", x.title), + ): group_name = group.title assert group_name if group_name in skipsections: @@ -449,7 +452,7 @@ def generate_config( for i in group._group_actions if not isinstance(i, argparse._SubParsersAction) ] - for opt in option_actions: + for opt in sorted(option_actions, key=lambda x: x.option_strings[0][2:]): if "--help" in opt.option_strings: continue