Skip to content

Commit

Permalink
Move StrictInt ahead of StrictFloat in model
Browse files Browse the repository at this point in the history
In newer pydantic this converts a 0 to 0.0 when serializing
to Json and this breaks when reading a record back that is
meant to be an integer. This changes in pydantic 2.2 whereas
2.1 behaved like 1.0.

This happens because the dynamic subclasses apply dynamic constraints
based on the specific record data model so they know that something
must be an integer.
  • Loading branch information
timj committed Aug 18, 2023
1 parent 86ee7ec commit 40e041c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/dimensions/_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SerializedDimensionRecord(_BaseModelCompat):
)

# Use strict types to prevent casting
record: dict[str, None | StrictFloat | StrictStr | StrictBool | StrictInt | tuple[int, int]] = Field(
record: dict[str, None | StrictInt | StrictFloat | StrictStr | StrictBool | tuple[int, int]] = Field(
...,
title="Dimension record keys and values.",
examples=[
Expand Down

0 comments on commit 40e041c

Please sign in to comment.