Skip to content

Make datamodels more DRY #11

Description

@Layf21

Make datamodels DRY

Motivation

Right now the datamodels are not as DRY as they could be. Every _from_dict and _from_list manually unpacks the JSON response. Abstracting this would:

  • Make adding new fields easier
  • Reduce boilerplate and clutter
  • Improve readability

Implementation

Haven’t fully thought through all the details yet, but the following could be replaced or generalized:

  • _from_dict
  • _from_list
  • Automatic and/or manual mapping from snake_case → camelCase

The idea is to have a generic base class for datamodels that handles most of this automatically, while still allowing overrides for special cases.

Issues / Considerations

Potential edge cases or challenges:

  • Error detection (e.g., type mismatches, unexpected API responses or missing fields)
  • Nested dataclasses
  • Lists of dataclasses

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions