(parser: Cmd2ArgumentParser)
| 1050 | cmdset_id = id(cmdset) |
| 1051 | |
| 1052 | def check_parser_uninstallable(parser: Cmd2ArgumentParser) -> None: |
| 1053 | try: |
| 1054 | subparsers_action = parser.get_subparsers_action() |
| 1055 | except ValueError: |
| 1056 | # No subcommands to check |
| 1057 | return |
| 1058 | |
| 1059 | # Prevent redundant traversal of parser aliases |
| 1060 | checked_parsers: set[Cmd2ArgumentParser] = set() |
| 1061 | |
| 1062 | for subparser in subparsers_action.choices.values(): |
| 1063 | if subparser in checked_parsers: |
| 1064 | continue |
| 1065 | checked_parsers.add(subparser) |
| 1066 | |
| 1067 | attached_cmdset_id = getattr(subparser, constants.PARSER_ATTR_COMMANDSET_ID, None) |
| 1068 | if attached_cmdset_id is not None and attached_cmdset_id != cmdset_id: |
| 1069 | raise CommandSetRegistrationError( |
| 1070 | f"Cannot uninstall CommandSet: '{subparser.prog}' is required by another CommandSet" |
| 1071 | ) |
| 1072 | check_parser_uninstallable(subparser) |
| 1073 | |
| 1074 | methods: list[tuple[str, Callable[..., Any]]] = inspect.getmembers( |
| 1075 | cmdset, |
nothing calls this directly
no test coverage detected