mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Improve callback data serialization (#1163)
* Improve callback data serialization * Added tests and changelog
This commit is contained in:
parent
fb3076d40f
commit
aad2de4324
3 changed files with 37 additions and 25 deletions
|
|
@ -67,7 +67,11 @@ class CallbackData(BaseModel):
|
|||
return ""
|
||||
if isinstance(value, Enum):
|
||||
return str(value.value)
|
||||
if isinstance(value, (int, str, float, Decimal, Fraction, UUID)):
|
||||
if isinstance(value, UUID):
|
||||
return value.hex
|
||||
if isinstance(value, bool):
|
||||
return str(int(value))
|
||||
if isinstance(value, (int, str, float, Decimal, Fraction)):
|
||||
return str(value)
|
||||
raise ValueError(
|
||||
f"Attribute {key}={value!r} of type {type(value).__name__!r}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue