@@ -950,11 +950,12 @@ def unregister_command_set(self, cmdset: CommandSet) -> None:
950950
951951 def _check_uninstallable (self , cmdset : CommandSet ) -> None :
952952 def check_parser_uninstallable (parser : argparse .ArgumentParser ) -> None :
953+ cmdset_id = id (cmdset )
953954 for action in parser ._actions :
954955 if isinstance (action , argparse ._SubParsersAction ):
955956 for subparser in action .choices .values ():
956- attached_cmdset = getattr (subparser , constants .PARSER_ATTR_COMMANDSET , None )
957- if attached_cmdset is not None and attached_cmdset is not cmdset :
957+ attached_cmdset_id = getattr (subparser , constants .PARSER_ATTR_COMMANDSET_ID , None )
958+ if attached_cmdset_id is not None and attached_cmdset_id != cmdset_id :
958959 raise CommandSetRegistrationError (
959960 'Cannot uninstall CommandSet when another CommandSet depends on it'
960961 )
@@ -1049,7 +1050,7 @@ def find_subcommand(action: argparse.ArgumentParser, subcmd_names: list[str]) ->
10491050 subcmd_parser .set_defaults (** defaults )
10501051
10511052 # Set what instance the handler is bound to
1052- setattr (subcmd_parser , constants .PARSER_ATTR_COMMANDSET , cmdset )
1053+ setattr (subcmd_parser , constants .PARSER_ATTR_COMMANDSET_ID , id ( cmdset ) )
10531054
10541055 # Find the argparse action that handles subcommands
10551056 for action in target_parser ._actions :
0 commit comments