Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python dataclass models #2684

Closed
samwelkanda opened this issue May 19, 2023 · 0 comments · Fixed by #2700
Closed

Python dataclass models #2684

samwelkanda opened this issue May 19, 2023 · 0 comments · Fixed by #2700
Assignees
Labels
enhancement New feature or request WIP

Comments

@samwelkanda
Copy link
Contributor

samwelkanda commented May 19, 2023

Python dataclasses are a classes that are designed to only hold data values. We should convert existing models from simple classes to dataclasses.

Benefits:

  1. Dataclasses are way more readable and maintainable as it removes the need for boilerplate code setters and getters for every property. This removes ~14 lines of code per property.
  2. Inbuilt str and repr methods for more helpful representation of data models.
  3. Doesn't break existing functionality. Works well with our current setup of serialization/deserialization.
  4. We can add convenience methods for serializing and deserializing data models to and from different formats, such as python dictionaries and json with to_dict(), to_json() methods respectively. This can make it much easier for end users to work with their data in different contexts and environments.
@samwelkanda samwelkanda self-assigned this May 19, 2023
@samwelkanda samwelkanda added enhancement New feature or request and removed Needs: Triage 🔍 labels May 19, 2023
@github-project-automation github-project-automation bot moved this to Todo in Kiota May 19, 2023
@samwelkanda samwelkanda moved this from Todo to In Progress in Kiota May 19, 2023
@samwelkanda samwelkanda changed the title Python pydantic models Python dataclass models May 23, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Kiota May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request WIP
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant