Repository navigation
Implement base model class with serialization helpers #36
Description
Activity
- addedGrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Campaign: Official Campaign | FWC26
on Jul 20, 2026 KodeSage commented
on Jul 21, 2026 ContributorMore actionsplease assign this issue to me. I have experience designing Python SDKs with a strong focus on maintainability, type safety, and clean model abstractions. I've worked with Pydantic-based models, centralized validation, and reusable base classes that reduce duplication while keeping APIs intuitive and consistent.
For this issue, I would introduce a shared ShadeObject base model in src/shade/models/base.py and expose it through src/shade/models/init.py. The base class would use ConfigDict(populate_by_name=True, extra="allow") to support flexible API responses while preserving type validation. I'd implement from_dict() and to_dict() helpers to provide a consistent serialization interface, along with a custom repr that highlights the model's class name and primary identifier for easier debugging.grantfox-oss commented
on Jul 21, 2026 grantfox-ossboton Jul 21, 2026 – with GrantFox OSSMore actionsgrantfox-oss commented
on Jul 24, 2026 grantfox-ossboton Jul 24, 2026 – with GrantFox OSSMore actions🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign | FWC26 campaign!
@KodeSage's PR #47 was approved and merged by @codebestia.
🏆 @KodeSage: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (242 total points). Track your full progress on GrantFox.
👏 Great work, @KodeSage! Keep contributing to ShadeProtocol.
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.