original_docstring: 
          Encodes CWT with MAC, signing or encryption.
          This is a wrapper function of the following functions for easy use:
  
          * :func:`encode_and_mac <cwt.CWT.encode_and_mac>`
          * :func:`encode_and_sign <cwt.CWT.encode_and_sign>`
          * :func:`encode_and_encrypt <cwt.CWT.encode_and_encrypt>`
  
          Therefore, it must be clear whether the use of the specified key is for MAC,
          signing, or encryption. For this purpose, the key must have the ``key_ops``
          parameter set to identify the usage.
  
          Args:
              claims (Union[Claims, Dict[str, Any], Dict[int, Any], bytes]): A CWT
                  claims object, or a JWT claims object, text string or byte string.
              key (COSEKeyInterface): A COSE key used to generate a MAC for the claims.
              nonce (bytes): A nonce for encryption.
              recipients (Optional[List[RecipientInterface]]): A list of recipient
                  information structures.
              signers (List[Signer]): A list of signer information structures for
                  multiple signer cases.
              tagged (bool): An indicator whether the response is wrapped by CWT
                  tag(61) or not.
          Returns:
              bytes: A byte string of the encoded CWT.
          Raises:
              ValueError: Invalid arguments.
              EncodeError: Failed to encode the claims.
          
docstring: Encodes CWT with MAC, signing or encryption.
  This is a wrapper function of the following functions for easy use.
  
  
  
  Therefore, it must be clear whether the use of the specified key is for MAC,
  signing, or encryption. For this purpose, the key must have the ``key_ops``
  parameter set to identify the usage.
docstring_tokens: Encodes CWT with MAC signing or encryption . This is a wrapper function of the following functions for easy use . Therefore it must be clear whether the use of the specified key is for MAC signing or encryption . For this purpose the key must have the ` ` key_ops ` ` parameter set to identify the usage .
code: def encode(
          self,
          claims: Union[Claims, Dict[str, Any], Dict[int, Any], bytes],
          key: COSEKeyInterface,
          nonce: bytes = b"",
          recipients: Optional[List[RecipientInterface]] = None,
          signers: List[Signer] = [],
          tagged: bool = False,
      ) -> bytes:
          """
          Encodes CWT with MAC, signing or encryption.
          This is a wrapper function of the following functions for easy use:
  
          * :func:`encode_and_mac <cwt.CWT.encode_and_mac>`
          * :func:`encode_and_sign <cwt.CWT.encode_and_sign>`
          * :func:`encode_and_encrypt <cwt.CWT.encode_and_encrypt>`
  
          Therefore, it must be clear whether the use of the specified key is for MAC,
          signing, or encryption. For this purpose, the key must have the ``key_ops``
          parameter set to identify the usage.
  
          Args:
              claims (Union[Claims, Dict[str, Any], Dict[int, Any], bytes]): A CWT
                  claims object, or a JWT claims object, text string or byte string.
              key (COSEKeyInterface): A COSE key used to generate a MAC for the claims.
              nonce (bytes): A nonce for encryption.
              recipients (Optional[List[RecipientInterface]]): A list of recipient
                  information structures.
              signers (List[Signer]): A list of signer information structures for
                  multiple signer cases.
              tagged (bool): An indicator whether the response is wrapped by CWT
                  tag(61) or not.
          Returns:
              bytes: A byte string of the encoded CWT.
          Raises:
              ValueError: Invalid arguments.
              EncodeError: Failed to encode the claims.
          """
          if isinstance(claims, Claims):
              return self._encode(claims, key, nonce, recipients, signers, tagged)
          if isinstance(claims, str):
              claims = claims.encode("utf-8")
          if isinstance(claims, bytes):
              try:
                  claims = Claims.from_json(claims, self._claim_names)
              except ValueError:
                  return self._encode(claims, key, nonce, recipients, signers, tagged)
          else:
              # Following code causes mypy error:
              # for k, v in claims.items():
              #     if isinstance(k, str):
              #         claims = Claims.from_json(claims)
              #     break
              # To avoid the error:
              json_claims: Dict[str, Any] = {}
              for k, v in claims.items():
                  if isinstance(k, str):
                      json_claims[k] = v
              if json_claims:
                  claims = Claims.from_json(json_claims, self._claim_names)
          return self._encode(claims, key, nonce, recipients, signers, tagged)
code_tokens: def encode ( self , claims : Union [ Claims , Dict [ str , Any ] , Dict [ int , Any ] , bytes ] , key : COSEKeyInterface , nonce : bytes = b"" , recipients : Optional [ List [ RecipientInterface ] ] = None , signers : List [ Signer ] = [ ] , tagged : bool = False , ) -> bytes : if isinstance ( claims , Claims ) : return self . _encode ( claims , key , nonce , recipients , signers , tagged ) if isinstance ( claims , str ) : claims = claims . encode ( "utf-8" ) if isinstance ( claims , bytes ) : try : claims = Claims . from_json ( claims , self . _claim_names ) except ValueError : return self . _encode ( claims , key , nonce , recipients , signers , tagged ) else : json_claims : Dict [ str , Any ] = { } for k , v in claims . items ( ) : if isinstance ( k , str ) : json_claims [ k ] = v if json_claims : claims = Claims . from_json ( json_claims , self . _claim_names ) return self . _encode ( claims , key , nonce , recipients , signers , tagged )
short_docstring: Encodes CWT with MAC, signing or encryption.
short_docstring_tokens: Encodes CWT with MAC signing or encryption .
comment: """
          Encodes CWT with MAC, signing or encryption.
          This is a wrapper function of the following functions for easy use:
  
          * :func:`encode_and_mac <cwt.CWT.encode_and_mac>`
          * :func:`encode_and_sign <cwt.CWT.encode_and_sign>`
          * :func:`encode_and_encrypt <cwt.CWT.encode_and_encrypt>`
  
          Therefore, it must be clear whether the use of the specified key is for MAC,
          signing, or encryption. For this purpose, the key must have the ``key_ops``
          parameter set to identify the usage.
  
          Args:
              claims (Union[Claims, Dict[str, Any], Dict[int, Any], bytes]): A CWT
                  claims object, or a JWT claims object, text string or byte string.
              key (COSEKeyInterface): A COSE key used to generate a MAC for the claims.
              nonce (bytes): A nonce for encryption.
              recipients (Optional[List[RecipientInterface]]): A list of recipient
                  information structures.
              signers (List[Signer]): A list of signer information structures for
                  multiple signer cases.
              tagged (bool): An indicator whether the response is wrapped by CWT
                  tag(61) or not.
          Returns:
              bytes: A byte string of the encoded CWT.
          Raises:
              ValueError: Invalid arguments.
              EncodeError: Failed to encode the claims.
          """$SEP$# Following code causes mypy error:$SEP$# for k, v in claims.items():$SEP$#     if isinstance(k, str):$SEP$#         claims = Claims.from_json(claims)$SEP$#     break$SEP$# To avoid the error: