diff --git a/gcloud/datastore/entity.py b/gcloud/datastore/entity.py index 034e11f10212..92f2e0c650cf 100644 --- a/gcloud/datastore/entity.py +++ b/gcloud/datastore/entity.py @@ -19,7 +19,7 @@ from gcloud.datastore.key import Key -class Entity(dict): # pylint: disable=too-many-public-methods +class Entity(dict): """:type dataset: :class:`gcloud.datastore.dataset.Dataset` :param dataset: The dataset in which this entity belongs. @@ -91,7 +91,9 @@ def key(self, key=None): :type key: :class:`glcouddatastore.key.Key` :param key: The key you want to set on the entity. - :returns: Either the current key or the :class:`Entity`. + :rtype: :class:`gcloud.datastore.key.Key` or :class:`Entity`. + :returns: Either the current key (on get) or the current + object (on set). >>> entity.key(my_other_key) # This returns the original entity. @@ -137,7 +139,7 @@ def from_key(cls, key): return cls().key(key) @classmethod - def from_protobuf(cls, pb, dataset=None): # pylint: disable=invalid-name + def from_protobuf(cls, pb, dataset=None): """Factory method for creating an entity based on a protobuf. The protobuf should be one returned from the Cloud Datastore @@ -176,9 +178,7 @@ def reload(self): """ # Note that you must have a valid key, otherwise this makes no sense. - # pylint: disable=maybe-no-member entity = self.dataset().get_entity(self.key().to_protobuf()) - # pylint: enable=maybe-no-member if entity: self.update(entity) @@ -190,26 +190,20 @@ def save(self): :rtype: :class:`gcloud.datastore.entity.Entity` :returns: The entity with a possibly updated Key. """ - # pylint: disable=maybe-no-member key_pb = self.dataset().connection().save_entity( dataset_id=self.dataset().id(), key_pb=self.key().to_protobuf(), properties=dict(self)) - # pylint: enable=maybe-no-member # If we are in a transaction and the current entity needs an # automatically assigned ID, tell the transaction where to put that. transaction = self.dataset().connection().transaction() - # pylint: disable=maybe-no-member if transaction and self.key().is_partial(): transaction.add_auto_id_entity(self) - # pylint: enable=maybe-no-member if isinstance(key_pb, datastore_pb.Key): updated_key = Key.from_protobuf(key_pb) # Update the path (which may have been altered). - # pylint: disable=maybe-no-member key = self.key().path(updated_key.path()) - # pylint: enable=maybe-no-member self.key(key) return self @@ -222,20 +216,13 @@ def delete(self): set on the entity. Whatever is stored remotely using the key on the entity will be deleted. """ - # NOTE: pylint thinks key() is an Entity, hence key().to_protobuf() - # is not defined. This is because one branch of the return - # in the key() definition returns self. - # pylint: disable=maybe-no-member self.dataset().connection().delete_entity( dataset_id=self.dataset().id(), key_pb=self.key().to_protobuf()) - # pylint: enable=maybe-no-member def __repr__(self): # pragma NO COVER # An entity should have a key all the time (even if it's partial). if self.key(): - # pylint: disable=maybe-no-member return '' % (self.key().path(), super(Entity, self).__repr__()) - # pylint: enable=maybe-no-member else: return '' % (super(Entity, self).__repr__())