code: def unload(self, key):
          
          assert isinstance(key, PGPKey)
          pkid = id(key)
          if pkid in self._keys:
              # remove references
              [ kd.remove(pkid) for kd in [self._pubkeys, self._privkeys] if pkid in kd ]
              # remove the key
              self._keys.pop(pkid)
  
              # remove aliases
              for m, a in [ (m, a) for m in self._aliases for a, p in m.items() if p == pkid ]:
                  m.pop(a)
                  # do a re-sort of this alias if it was not unique
                  if a in self:
                      self._sort_alias(a)
  
              # if key is a primary key, unload its subkeys as well
              if key.is_primary:
                  [ self.unload(sk) for sk in key.subkeys.values() ]
docs: Unload a loaded key and its subkeys.
  
          The easiest way to do this is to select a key using :py:meth:`PGPKeyring.key` first::
  
              with keyring.key("DSA von TestKey") as key:
                  keyring.unload(key)
  
          :param key: The key to unload.
          :type key: :py:obj:`PGPKey`