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

Nested classes with SetField / SequenceField attributes #37

Open
syonekura opened this issue Mar 13, 2019 · 0 comments
Open

Nested classes with SetField / SequenceField attributes #37

syonekura opened this issue Mar 13, 2019 · 0 comments

Comments

@syonekura
Copy link

Hi, first of all, thanks for developing this great library.

I have a couple of classes with the following structure:

import related


@related.immutable()
class A:
    a = related.SetField(str)


@related.immutable()
class B:
    b = related.SetField(A)


b = B(b=[
    A(a=list('asda'))
])
related.to_json(b)

When I run this code I get a TypeError:

Traceback (most recent call last):
  File "/.../fixtures/issue.py", line 15, in <module>
    A(a=list('asda'))
  File "<attrs generated init f72a7b4d1a1c90a964e7a0a277e0d59a773ff62a>", line 3, in __init__
  File "/.../virtualenvs/5Foejugn/lib/python3.6/site-packages/related/converters.py", line 90, in __call__
    args = {to_model(self.cls, value) for value in values}
  File "/.../virtualenvs/5Foejugn/lib/python3.6/site-packages/related/converters.py", line 90, in <setcomp>
    args = {to_model(self.cls, value) for value in values}
  File "<attrs generated hash 5c9557479baa8d43a71218b554b729b7a6f45a5c>", line 4, in __hash__
TypeError: unhashable type: 'TypedSet'

For some reason I cannot transform to JSON/YML a class with a Set of Sets, am I doing something wrong or is this a bug?

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

No branches or pull requests

1 participant