File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1025,18 +1025,22 @@ def unregister_command_set(self, cmdset: CommandSet) -> None:
10251025 self ._installed_command_sets .remove (cmdset )
10261026
10271027 def _check_uninstallable (self , cmdset : CommandSet ) -> None :
1028+ cmdset_id = id (cmdset )
1029+
10281030 def check_parser_uninstallable (parser : Cmd2ArgumentParser ) -> None :
1029- cmdset_id = id (cmdset )
10301031 try :
10311032 subparsers_action = parser ._get_subparsers_action ()
1032- for subparser in subparsers_action .choices .values ():
1033- attached_cmdset_id = getattr (subparser , constants .PARSER_ATTR_COMMANDSET_ID , None )
1034- if attached_cmdset_id is not None and attached_cmdset_id != cmdset_id :
1035- raise CommandSetRegistrationError ('Cannot uninstall CommandSet when another CommandSet depends on it' )
1036- check_parser_uninstallable (cast (Cmd2ArgumentParser , subparser ))
10371033 except ValueError :
10381034 # No subcommands to check
1039- pass
1035+ return
1036+
1037+ for subparser in subparsers_action .choices .values ():
1038+ attached_cmdset_id = getattr (subparser , constants .PARSER_ATTR_COMMANDSET_ID , None )
1039+ if attached_cmdset_id is not None and attached_cmdset_id != cmdset_id :
1040+ raise CommandSetRegistrationError (
1041+ f"Cannot uninstall CommandSet: '{ subparser .prog } ' is required by another CommandSet"
1042+ )
1043+ check_parser_uninstallable (cast (Cmd2ArgumentParser , subparser ))
10401044
10411045 methods : list [tuple [str , Callable [..., Any ]]] = inspect .getmembers (
10421046 cmdset ,
You can’t perform that action at this time.
0 commit comments