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

event can't accept tuples/lists #3393

Closed
ymotongpoo opened this issue Jul 3, 2022 · 3 comments
Closed

event can't accept tuples/lists #3393

ymotongpoo opened this issue Jul 3, 2022 · 3 comments

Comments

@ymotongpoo
Copy link

As reported at StackOverflow, I tried to take the statistics of generated list values with event.

@dataclass(frozen=True)
class Foo:
    x: int
    y: str

    def __hash__(self):
        return hash((self.x, self.y))

@given(lists(builds(Foo, integers(), text()), max_size=3))
def test_foo(l):
    t = tuple(l)
    event(t)

The code above raised an TypeError saying:

self = <WeakKeyDictionary at 0x105c17430>, key = ()

    def __getitem__(self, key):
>       return self.data[ref(key)]
E       TypeError: cannot create weak reference to 'tuple' object

../../../.pyenv/versions/3.10.4/lib/python3.10/weakref.py:416: TypeError

Because the tuple is builtin and I couldn't resolve this weakref issue easily. @Zac-HD suggested to use 'str' instead of tuples, but it would be great if event can accepts tuples and other hashable objects.

@Zac-HD
Copy link
Member

Zac-HD commented Jul 3, 2022

Fixed by #3392 / https://hypothesis.readthedocs.io/en/latest/changes.html#v6-48-3 😁

@Zac-HD Zac-HD closed this as completed Jul 3, 2022
@ymotongpoo
Copy link
Author

Thank you for the quick fix!

@Zac-HD
Copy link
Member

Zac-HD commented Jul 3, 2022

No problem! If you run into anything else, please do open another issue 😎

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