code: def revoke(self, target, **prefs):
          
          hash_algo = prefs.pop('hash', None)
          if isinstance(target, PGPUID):
              sig_type = SignatureType.CertRevocation
  
          elif isinstance(target, PGPKey):
              ##TODO: check to make sure that the key that is being revoked:
              #        - is this key
              #        - is one of this key's subkeys
              #        - specifies this key as its revocation key
              if target.is_primary:
                  sig_type = SignatureType.KeyRevocation
  
              else:
                  sig_type = SignatureType.SubkeyRevocation
  
          else:  # pragma: no cover
              raise TypeError
  
          sig = PGPSignature.new(sig_type, self.key_algorithm, hash_algo, self.fingerprint.keyid)
  
          # signature options that only make sense when revoking
          reason = prefs.pop('reason', RevocationReason.NotSpecified)
          comment = prefs.pop('comment', "")
          sig._signature.subpackets.addnew('ReasonForRevocation', hashed=True, code=reason, string=comment)
  
          return self._sign(target, sig, **prefs)
docs: Revoke a key, a subkey, or all current certification signatures of a User ID that were generated by this key so far.
  
          :param target: The key to revoke
          :type target: :py:obj:`PGPKey`, :py:obj:`PGPUID`
          :raises: :py:exc:`~pgpy.errors.PGPError` if the key is passphrase-protected and has not been unlocked
          :raises: :py:exc:`~pgpy.errors.PGPError` if the key is public
          :returns: :py:obj:`PGPSignature`
  
          In addition to the optional keyword arguments accepted by :py:meth:`PGPKey.sign`, the following optional
          keyword arguments can be used with :py:meth:`PGPKey.revoke`.
  
          :keyword reason: Defaults to :py:obj:`constants.RevocationReason.NotSpecified`
          :type reason: One of :py:obj:`constants.RevocationReason`.
          :keyword comment: Defaults to an empty string.
          :type comment: ``str``