GoodRx / attrs_sqlalchemy

Add dunder-methods to SQLAlchemy models with attrs
https://pypi.org/project/attrs-sqlalchemy/
MIT License
2 stars 2 forks source link

attrs 17.1.0+ compatibility #11

Closed rouge8 closed 6 years ago

rouge8 commented 7 years ago

attrs 17.1.0 changed the default for hash to None, which makes objects unhashable.

In #10, we set hash=False so that we can continue to use objects as keys in dictionaries, but without attempting to hash by value. This matches SQLAlchemy's default behavior.

Having __hash__ not match __cmp__ is weird, which raises the question: should we set cmp=False too? I kind of think we should, but that means attrs_sqlalchemy becomes attr.s(repr=True, hash=False, init=False, cmp=False), so all we're using attrs for is the repr.

I think we'll go ahead with #10, add a deprecation warning to attrs_sqlalchemy.attrs_sqlalchemy, and add a new decorator attrs_sqlalchemy.attrs_sqlalchemy_repr that provides only the repr.

Thoughts?

rouge8 commented 6 years ago

Closed by #14