Skip to content

Commit

Permalink
fix(config): Serialize hex bytes to hex string
Browse files Browse the repository at this point in the history
  • Loading branch information
fkglr authored and rumpelsepp committed Jan 21, 2025
1 parent ecd9305 commit 2b0193a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/gallia/command/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
get_args,
)

from pydantic import BeforeValidator
from pydantic import BeforeValidator, PlainSerializer
from pydantic.fields import _FromFieldInfoInputs
from pydantic_core import PydanticUndefined

Expand Down Expand Up @@ -65,6 +65,7 @@ def err_int(x: str, base: int) -> int:
HexBytes = Annotated[
bytes,
BeforeValidator(lambda x: x if isinstance(x, bytes) else binascii.unhexlify(x)),
PlainSerializer(lambda x: binascii.hexlify(x)),
]
"""
Special type for a field, which parses bytes from hex strings.
Expand Down

0 comments on commit 2b0193a

Please sign in to comment.