code: def new(cls, key_algorithm, key_size):
          
          # new private key shell first
          key = PGPKey()
  
          if key_algorithm in {PubKeyAlgorithm.RSAEncrypt, PubKeyAlgorithm.RSASign}:  # pragma: no cover
              warnings.warn('{:s} is deprecated - generating key using RSAEncryptOrSign'.format(key_algorithm.name))
              key_algorithm = PubKeyAlgorithm.RSAEncryptOrSign
  
          # generate some key data to match key_algorithm and key_size
          key._key = PrivKeyV4.new(key_algorithm, key_size)
  
          return key
docs: Generate a new PGP key
  
          :param key_algorithm: Key algorithm to use.
          :type key_algorithm: A :py:obj:`~constants.PubKeyAlgorithm`
          :param key_size: Key size in bits, unless `key_algorithm` is :py:obj:`~constants.PubKeyAlgorithm.ECDSA` or
                 :py:obj:`~constants.PubKeyAlgorithm.ECDH`, in which case it should be the Curve OID to use.
          :type key_size: ``int`` or :py:obj:`~constants.EllipticCurveOID`
          :return: A newly generated :py:obj:`PGPKey`