DurgNomis-drol / mytoyota

Python client for Toyota Connected Services API
MIT License
74 stars 28 forks source link

Use `CustomBaseModel` on all endpoint models and make fields `Optional` #365

Closed CM000n closed 2 weeks ago

CM000n commented 4 weeks ago

If you take a look at the merge requests in this project, most of them were created by breaking model assumptions and setting individual fields to Optional.

This merge request introduces a CustomBaseModel that automatically generates None values for values that do not match the data types of the model assumptions. In addition, all data types of the fields in the models were set to Optional.

This does not immediately make things better, but at least an error is no longer immediately thrown if the model assumptions break. This means that the models and the mytoyota lib remain functional within the scope of the information available and can continue to be used by end users if Toyota changes something in the API again.

codecov[bot] commented 4 weeks ago

Codecov Report

Attention: Patch coverage is 99.77011% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.80%. Comparing base (5310e09) to head (25276ae). Report is 1 commits behind head on master.

Files Patch % Lines
mytoyota/utils/models.py 92.85% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #365 +/- ## ========================================== + Coverage 82.58% 82.80% +0.22% ========================================== Files 29 30 +1 Lines 1418 1442 +24 ========================================== + Hits 1171 1194 +23 - Misses 247 248 +1 ``` | [Flag](https://app.codecov.io/gh/DurgNomis-drol/mytoyota/pull/365/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Hansen) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/DurgNomis-drol/mytoyota/pull/365/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Hansen) | `82.80% <99.77%> (+0.22%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Hansen#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.