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

Unstructuring a tuple of objects no longer works #125

Closed
gmacon opened this issue Feb 18, 2021 · 4 comments
Closed

Unstructuring a tuple of objects no longer works #125

gmacon opened this issue Feb 18, 2021 · 4 comments

Comments

@gmacon
Copy link

gmacon commented Feb 18, 2021

  • cattrs version: 1.2.0
  • Python version: 3.7.9
  • Operating System: Linux

Description

There are a few spots in the code where I unstructure a tuple of attrs objects in preparation for JSON-encoding them. This stopped working with 1.2.0.

What I Did

Here's a minimal reproducer:

#!/usr/bin/env python3

import attr
import cattr

@attr.define()
class Foo:
    foo: str

assert cattr.unstructure((Foo("foo"),)) == ({"foo": "foo"},)

I've bisected this to 53fd2ad. From looking at that commit quickly, I'm guessing that switching from _subclass(Sequence) to is_sequence is causing a tuple to no longer be considered a sequence.

@Tinche
Copy link
Member

Tinche commented Feb 18, 2021

Oh interesting. Taking a look.

@Tinche
Copy link
Member

Tinche commented Feb 19, 2021

Fix prepared here: https://github.com/Tinche/cattrs/pull/126, need to test it a little more

@gmacon
Copy link
Author

gmacon commented Feb 19, 2021

Nice, thanks!

@Tinche
Copy link
Member

Tinche commented Feb 20, 2021

Fix committed, will go out with the next release (1.3.0).

@Tinche Tinche closed this as completed Feb 20, 2021
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

2 participants