Skip to content

pydantic.color.Color is not hashable in 1.10.0 release #4454

@Czaki

Description

@Czaki

Initial Checks

  • I have searched GitHub for a duplicate issue and I'm sure this is something new
  • I have searched Google & StackOverflow for a solution and couldn't find anything
  • I have read and followed the docs and still think this is a bug
  • I am confident that the issue is with pydantic (not my code, or another library in the ecosystem like FastAPI or mypy)

Description

In pydantic 1.9.2 (and earlier), the Color class was Hashable. in release 1.10.0 it is not hashable that broke usage color as an argument to function decorated with @lru_cache from std lib. (napari/napari#4995)

A I do not see public method for mutate such object IO thin that it is deprecation.

Example Code

pydantic 1.9.2

In [1]: from pydantic.color import Color                                                     

In [2]: a = Color((0,0,0))                                                                   

In [3]: hash(a)                                                                              
Out[3]: 8771047785283

pydantic 1.10.0

In [1]: from pydantic.color import Color                                                     

In [2]: a = Color((0,0,0))                                                                   

In [3]: hash(a)                                                                              
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-57b555d30865> in <module>
----> 1 hash(a)

TypeError: unhashable type: 'Color'


### Python, Pydantic & OS Version

```Text
pydantic 1.9.2 vs pydantic 1.10.0 tested on ubuntu and macos m1.

Affected Components

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions