Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #533: add key and entity equality methods #615

Merged
merged 7 commits into from
Feb 12, 2015
Merged

Fix #533: add key and entity equality methods #615

merged 7 commits into from
Feb 12, 2015

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented Feb 10, 2015

Add Key.{__eq__,__ne__,__hash__}, including correct handling of prefixed dataset IDs.

Move helpers._dataset_ids_equal -> key, for better separation of concerns (and to avoid a cycle).

Add Entity.{__eq__,__ne__}.

Fixes #533

Move '_dataset_ids_equal' from 'helpers' -> 'key', because it is only
useful for keys, and we don't want the cycle.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 10, 2015
@tseaver tseaver changed the title 533 key and entity equality Fix #533: add key and entity equality methods Feb 10, 2015
@tseaver
Copy link
Contributor Author

tseaver commented Feb 10, 2015

Note that this PR assumes my "incomplete keys never compare equal" simplification.

@dhermes
Copy link
Contributor

dhermes commented Feb 12, 2015

I like the simplification. Reviewing now.

:returns: True if the entities compare equal, else False.
"""
if not isinstance(other, Entity):
raise NotImplementedError

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented Feb 12, 2015

Overall looks good, pending my comments.

@dhermes
Copy link
Contributor

dhermes commented Feb 12, 2015

@tseaver

>>> bool(NotImplemented)
True

Hence key == object() is truthy (UPDATE: I missed @tseaver comment.)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 680800d on tseaver:533-key_and_entity_equality into b395360 on GoogleCloudPlatform:master.

tseaver added a commit that referenced this pull request Feb 12, 2015
Fix #533:  add key and entity equality methods
@tseaver tseaver merged commit 9a918cf into googleapis:master Feb 12, 2015
@tseaver tseaver deleted the 533-key_and_entity_equality branch February 12, 2015 19:19
dhermes added a commit to dhermes/google-cloud-python that referenced this pull request Feb 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DISCUSSION: Implement Key.__eq__ and Entity.__eq__
4 participants