-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add 6 character only as_hex
e.g. Color("red").as_hex(format="long") == #ff0000
#66
Comments
Thanks @DJRHails for this feature request. As you may know, We are working on We moved this and some other extra types to a separate package pydantic-extra-types. I am moving this issue there. |
Appreciated @hramezani! |
PR welcome. 👍 The signature should be |
Great I'll get a PR in tonight |
Initial Checks
Description
Currently I use a custom function for converting Pydantic Color to hex, to remove the unexpected return value of
#f00
when I expect#ff0000
instead.I propose (and happy to contribute), an optional parameter e.g.
format="long"
to allow non-compressed hex values.Affected Components
.model_dump()
and.model_dump_json()
model_construct()
, pickling, private attributes, ORM modeThe text was updated successfully, but these errors were encountered: