-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Enhancement description
There are a lot of hardcoded values used for object mapping for models (from_dict method) within the library. For instance, this is the Section class mapping from dict:
@dataclass
class Section:
id: str
name: str
order: int
project_id: str
@classmethod
def from_dict(cls, obj):
return cls(
id=obj["id"],
name=obj["name"],
order=obj["order"],
project_id=obj["project_id"],
)I suggest allowing some third-party object mapping library like pydantic or msgspec to handle this logic.
The problem it solves
The current implementation with hardcoded values in the from_dict method makes the code less maintainable and flexible. By integrating a third-party library for object mapping, we can improve readability, maintainability, and reduce the chances of errors.
Alternatives
Currently, we could continue with the hardcoded approach, but it may lead to increased complexity and maintenance overhead as the project grows. Alternatively, we can manually implement more flexible object mapping methods, but this may also introduce additional boilerplate code and potential errors.
Use case / screenshots
N/A
Additional information
Integrating a third-party library for object mapping will not only streamline the codebase but also potentially introduce additional features such as validation and serialization, which can enhance the robustness and usability of the library.