From 4c3598b891dae53e58bf3d579c3fbaaef3ef9be4 Mon Sep 17 00:00:00 2001 From: Michael Dunn Date: Tue, 23 Jan 2018 12:00:26 -0500 Subject: [PATCH] Fix for python-attrs/attrs#253 breaking change --- attrs_sqlalchemy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/attrs_sqlalchemy.py b/attrs_sqlalchemy.py index ce86946..2c61b88 100644 --- a/attrs_sqlalchemy.py +++ b/attrs_sqlalchemy.py @@ -68,7 +68,13 @@ def wrap(cls): # which won't be ready yet. for name in inspect(cls).columns.keys() } - return attr.s(cls, these=these, init=False, hash=False) + those = {} + for attribute in these: + those[attribute] = cls.__dict__[attribute] + s = attr.s(these=these, init=False, hash=False)(cls) + for attribute in those: + setattr(cls, attribute, those[attribute]) + return s # `maybe_cls` depends on the usage of the decorator. It's a class if it's # used as `@attrs_sqlalchemy` but `None` if it's used as