-
Notifications
You must be signed in to change notification settings - Fork 35
Migrate from dataclasses-json to dataclass-wizard
#179
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the project from using dataclasses-json to dataclass-wizard for JSON serialization, addressing integration issues with pyright while potentially improving performance and dependency footprint.
- Replace DataClassJsonMixin with JSONPyWizard in all model classes
- Update dependency declarations in pyproject.toml and adjust documentation accordingly
- Modify Due and Task conversion logic to align with dataclass-wizard usage
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| todoist_api_python/models.py | Migration of model classes to use dataclass-wizard along with minor logic changes |
| pyproject.toml | Update dependency from dataclasses-json to dataclass-wizard |
| README.md | Update supported Python versions statement |
| CHANGELOG.md | Change changelog entry to reflect migration to dataclass-wizard |
Comments suppressed due to low confidence (2)
todoist_api_python/models.py:57
- The post_init method in the Due class now sets 'self.datetime' to 'self.date' when both date and timezone are present, which might not fully replicate the previous behavior. Please confirm that this simplified assignment meets the intended logic.
if not self.datetime and (self.date and self.timezone):
todoist_api_python/models.py:93
- The removal of the conversion for the 'due' field in Task.from_quick_add_response could result in unprocessed due data. Verify that due data is correctly initialized using the new dataclass-wizard setup.
def from_quick_add_response(cls, obj: dict[str, Any]) -> Task:
|
As in before PRs, I'm merging so that I can keep iterating fast, but I would appreciate a review after the fact. Happy to make any improvement or accommodate any change we see fit. |
This is actually a good point by Copilot. Our updated code DOES replicate the old logic, but the old logic is pretty bizarre. 😅 |
lefcha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, but I wonder if it's worth all the hassle since we plan on moving to Pydantic anyway...
|
I'm not sure if we'll move to Pydantic. At least after reading @proxi's feedback, I don't it makes that much sense. It's quite a big dependency for almost no direct benefit to the consumer of the SDK, and we can get most of the advantages we'd want using a lighterweight alternative. The way I see it, this would stay for now. 🤔 |
Because of some minor issues related to the integration between
dataclasses-jsonand pyright, I ended up scouting their issue tracker, and was generally unimpressed — hundreds of issues, many without follow-up. I didn't find some areas of the code to be much better. The project doesn't seem like it's been actively maintainted for a while.Searching for (lightweight) alternatives, I came across dataclass-wizard and I suggest we use it instead: