Skip to content

Commit

Permalink
Removing pylint statements in datastore.entity.
Browse files Browse the repository at this point in the history
Rolls back changes put in googleapis#189 that are no longer
necessary.
  • Loading branch information
dhermes committed Oct 14, 2014
1 parent 5d46c45 commit 9a160b5
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions gcloud/datastore/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
<Entity[{'kind': 'OtherKeyKind', 'id': 1234}] {'property': 'value'}>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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 '<Entity%s %s>' % (self.key().path(),
super(Entity, self).__repr__())
# pylint: enable=maybe-no-member
else:
return '<Entity %s>' % (super(Entity, self).__repr__())

0 comments on commit 9a160b5

Please sign in to comment.