All response models should share a common base that provides from_dict(data: dict), to_dict(), and a readable __repr__. Using Pydantic as the base eliminates boilerplate validation and gives free type coercion.
Proposed Steps:
- Create
src/shade/models/__init__.py and src/shade/models/base.py.
- Define
ShadeObject(pydantic.BaseModel) with model_config = ConfigDict(populate_by_name=True, extra="allow").
- Add
to_dict() method wrapping model.model_dump().
- Add a
classmethod from_dict(cls, data: dict) that constructs the model.
- Override
__repr__ to show class name and primary ID field.
Acceptance Criteria:
- All models can be round-tripped through
from_dict(m.to_dict()) without data loss.
- Unknown fields from the API are accepted without raising (
extra="allow").
repr(model) shows the class name and key ID field.
- Pydantic validation errors surface as
InvalidRequestError, not raw ValidationError.
All response models should share a common base that provides
from_dict(data: dict),to_dict(), and a readable__repr__. Using Pydantic as the base eliminates boilerplate validation and gives free type coercion.Proposed Steps:
src/shade/models/__init__.pyandsrc/shade/models/base.py.ShadeObject(pydantic.BaseModel)withmodel_config = ConfigDict(populate_by_name=True, extra="allow").to_dict()method wrappingmodel.model_dump().classmethod from_dict(cls, data: dict)that constructs the model.__repr__to show class name and primary ID field.Acceptance Criteria:
from_dict(m.to_dict())without data loss.extra="allow").repr(model)shows the class name and key ID field.InvalidRequestError, not rawValidationError.