Skip to content

Style is unhashable #224

Description

@kdeldycke

Bug description

Style caches its click.style() keyword arguments on first call, in a field declared without compare=False and repr=False:

_style_kwargs: Optional[Dict[str, Any]] = dc.field(init=False, default=None)

To Reproduce

>>> from cloup import Style
>>> a, b = Style(fg="red"), Style(fg="red")
>>> a == b, hash(a) == hash(b)
(True, True)
>>> a("hello")
'\x1b[31mhello\x1b[0m'
>>> a == b
False
>>> hash(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 32, in __hash__
TypeError: unhashable type: 'dict'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions