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

Improve documentation of safety constraints on hashable objects #505

Merged
merged 5 commits into from
Feb 14, 2019

Conversation

gabbard
Copy link
Member

@gabbard gabbard commented Feb 14, 2019

Although #503 referred to cache_hash, on reflection it occurred to me that the concern is valid for all hashable objects. At the same time, I've clarified the documentation to be clear that if you mutate a cache_hash object or an object referred to in its hash computation, the resulting object hash code is undefined. This seemed better than making any more particular comment since it leaves the API uncommitted as to whether the hash code is computed at object-construction time or lazily on the first call to hash

This closes #503 .

Pull Request Check List

This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!

If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.

  • Added tests for changed code. (n/a, docs only)
  • [X ] New features have been added to our Hypothesis testing strategy. (n/a, docs only)
  • Changes or additions to public APIs are reflected in our type stubs (files ending in .pyi). (n/a, docs only)
    • ...and used in the stub test file tests/typing_example.py. (n/a, docs only)
  • Updated documentation for changed code.
    • New functions/classes have to be added to docs/api.rst by hand.
    • Changes to the signature of @attr.s() have to be added by hand too.
    • [X ] Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Documentation in .rst files is written using semantic newlines.
  • Changes (and possible deprecations) have news fragments in changelog.d.

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

Ryan Gabbard added 4 commits October 31, 2018 17:04
Sync up to main attrs repository
Makes clear that hashable objects need to be deeply immutable, in
practice even if not in theory.

Closes python-attrs#503 .
@gabbard gabbard changed the title Improve documentation of safety constraints on hashable objects [WIP] Improve documentation of safety constraints on hashable objects Feb 14, 2019
@gabbard gabbard changed the title [WIP] Improve documentation of safety constraints on hashable objects Improve documentation of safety constraints on hashable objects Feb 14, 2019
@gabbard
Copy link
Member Author

gabbard commented Feb 14, 2019

@hynek : Ready for review.

@hynek hynek merged commit 659aa48 into python-attrs:master Feb 14, 2019
@hynek
Copy link
Member

hynek commented Feb 14, 2019

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Requirement for safety of cache_hash is stronger than documented
2 participants