code: def set(self, item: Union[Service, PublicKey]) -> 'DIDDoc':
          
  
          if isinstance(item, Service):
              self.service[item.id] = item
          elif isinstance(item, PublicKey):
              self.pubkey[item.id] = item
          else:
              raise BadDIDDocItem('Cannot add item {} to DIDDoc on DID {}'.format(item, self.did))
docs: Add or replace service or public key; return current DIDDoc.
  
          Raise BadDIDDocItem if input item is neither service nor public key.
  
          :param item: service or public key to set
          :return: current DIDDoc