Skip to content

Commit

Permalink
Make Factory hashable (#204)
Browse files Browse the repository at this point in the history
* Make Factory hashable

* Add PR#
  • Loading branch information
hynek authored and Tinche committed Jun 6, 2017
1 parent 303b2f6 commit 24815d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Changes:

- Fix *str* on Python 2 when ``slots=True``.
`#198 <https://github.com/python-attrs/attrs/issues/198>`_
- ``attr.Factory`` is now hashable again.
`#204 <https://github.com/python-attrs/attrs/issues/204>`_


----
Expand Down
2 changes: 1 addition & 1 deletion src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ def default(self, meth):
_CountingAttr = _add_cmp(_add_repr(_CountingAttr))


@attributes(slots=True, init=False)
@attributes(slots=True, init=False, hash=True)
class Factory(object):
"""
Stores a factory callable.
Expand Down
6 changes: 6 additions & 0 deletions tests/test_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,12 @@ def test_factory_takes_self(self):

assert i is i.x

def test_factory_hashable(self):
"""
Factory is hashable.
"""
assert hash(Factory(None, False)) == hash(Factory(None, False))

def test_convert_before_validate(self):
"""
Validation happens after conversion.
Expand Down

0 comments on commit 24815d7

Please sign in to comment.