This issue was brought up and closed as part of issue # 41592.
The add_subparsers method returns a protected _SubParsersAction instance. To add a sub-parser, the public add_parser method of the protected _SubParsersAction instance must be used.
- It is unexpected to require the use of a public method of a protected class instance.
- The protected return type breaks type hinting because
- protected and should not be imported
- it is not available for import
Real world use case example:
sub_parsers_action = parser.add_subparsers(...)
def build_subcmd(sub_parsers_action: _SubParsersAction):
...
The ask is to make the type of whatever is returned from add_subparsers public.
This issue was brought up and closed as part of issue # 41592.
The
add_subparsersmethod returns a protected_SubParsersActioninstance. To add a sub-parser, the publicadd_parsermethod of the protected_SubParsersActioninstance must be used.Real world use case example:
The ask is to make the type of whatever is returned from
add_subparserspublic.