pydantic / pydantic-extra-types

Extra Pydantic types.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add better representation for Color object

jjeff07 opened this issue · comments

I am trying to print out data models that use the Color class however the repr unlike BaseModel is showing rgb=XXX which is not valid for initilization.

from devtools import debug
from pydantic_extra_types.color import Color
color = Color('red')
"""
debug(color)
<input>:1 <module> (no code context for debug call, code inspection impossible)
    Color(
        'red',
        rgb=(
            255,
            0,
            0,
        ),
    ) (Color)
Color('red', rgb=(255, 0, 0))
"""
Color('red', rgb=(255, 0, 0))
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2023.2.2\plugins\python\helpers-pro\pydevd_asyncio\pydevd_asyncio_utils.py", line 114, in _exec_async_code
    result = func()
  File "<input>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'rgb'