code: def parse(cls, credentials) -> typing.Optional["Credentials"]:
          
          if credentials is None:
              return None
          elif isinstance(credentials, cls):
              return credentials
          elif isinstance(credentials, str):
              if credentials == "":
                  return None
              elif credentials.count(":") == 2:
                  return cls(*credentials.split(":"))
              else:
                  raise ValueError(
                      "Malformed credentials. Expected 3 colon-separated "
                      "parts, got %r." % (credentials, ))
          else:
              parts = list(credentials)
              if len(parts) == 0:
                  return None
              elif len(parts) == 3:
                  return cls(*parts)
              else:
                  raise ValueError(
                      "Malformed credentials. Expected 3 parts, "
                      "got %r." % (credentials, ))
docs: Parse/interpret some given credentials.
  
          These may take the form of:
  
          * An empty string.
  
          * An empty sequence.
  
          * A string, containing three parts (consumer key, token key, and token
            secret) separated by colons.
  
          * A sequence of three strings (consumer key, token key, and token
            secret).
  
          * None.