Skip to content

Implement base model class with serialization helpers #36

Description

@codebestia

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.

Activity

  1. KodeSage commented on Jul 21, 2026

    @KodeSage
    Contributor

    please 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.

  2. grantfox-oss commented on Jul 21, 2026

    @grantfox-oss

    🦊 GrantFox — @KodeSage has been assigned to this issue as part of the Official Campaign | FWC26 campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #36)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  3. grantfox-oss commented on Jul 24, 2026

    @grantfox-oss

    🎉 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions