Skip to content

Commit 56a7c97

Browse files
committed
Rename AppResponseModel to SelectiveSerializationModel
- Consolidate to using public serialization.py module - Remove duplicate _appresponse.py file - Rename AppResponseModel to SelectiveSerializationModel for clarity - Add documentation explaining the purpose (omitting None fields) - Addresses gatecat review comment on models.py:39
1 parent 1e213bf commit 56a7c97

File tree

3 files changed

+14
-45
lines changed

3 files changed

+14
-45
lines changed

chipflow_lib/_appresponse.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

chipflow_lib/config/models.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
BaseModel, PlainSerializer, WrapValidator
88
)
99

10-
from .._appresponse import AppResponseModel, OmitIfNone
10+
from ..serialization import SelectiveSerializationModel, OmitIfNone
1111

1212
class Process(Enum):
1313
"""
@@ -36,9 +36,11 @@ def __str__(self):
3636
]
3737

3838

39-
class VoltageRange(AppResponseModel):
39+
class VoltageRange(SelectiveSerializationModel):
4040
"""
41-
Models a voltage range for a power domain or IO
41+
Models a voltage range for a power domain or IO.
42+
43+
Optional fields (min, max, typical) are omitted from serialization when None.
4244
"""
4345
min: Annotated[Optional[Voltage], OmitIfNone()] = None
4446
max: Annotated[Optional[Voltage], OmitIfNone()] = None

chipflow_lib/serialization.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66

77
@dataclass
88
class OmitIfNone:
9+
"""Marker for fields that should be omitted from serialization when None."""
910
pass
1011

11-
class AppResponseModel(BaseModel):
12+
class SelectiveSerializationModel(BaseModel):
13+
"""
14+
Base model that supports selective field serialization.
15+
16+
Fields annotated with OmitIfNone() will be excluded from serialized
17+
output when their value is None. This provides cleaner JSON output
18+
for optional configuration fields.
19+
"""
1220
@model_serializer
1321
def _serialize(self):
1422
skip_if_none = set()

0 commit comments

Comments
 (0)