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

Update pydantic to 2.x and run automatic codemods #384

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- name: "⤵️ Check out code from GitHub"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: "Pytest"
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: "ubuntu-latest"
env:
OS: "ubuntu-latest"
Expand Down
52 changes: 26 additions & 26 deletions mytoyota/models/endpoints/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,49 @@


class _TermsActivityModel(CustomBaseModel):
time_stamp: Optional[datetime] = Field(alias="timeStamp")
version: Optional[str]
time_stamp: Optional[datetime] = Field(None, alias="timeStamp")
version: Optional[str] = None


class _AdditionalAttributesModel(CustomBaseModel):
is_terms_accepted: Optional[bool] = Field(alias="isTermsAccepted")
is_terms_accepted: Optional[bool] = Field(None, alias="isTermsAccepted")
terms_activity: Optional[List[_TermsActivityModel]] = Field("termsActivity")


class _EmailModel(CustomBaseModel):
email_address: Optional[str] = Field(alias="emailAddress")
email_type: Optional[str] = Field(alias="emailType")
email_verified: Optional[bool] = Field(alias="emailVerified")
verification_date: Optional[datetime] = Field(alias="verificationDate")
email_address: Optional[str] = Field(None, alias="emailAddress")
email_type: Optional[str] = Field(None, alias="emailType")
email_verified: Optional[bool] = Field(None, alias="emailVerified")
verification_date: Optional[datetime] = Field(None, alias="verificationDate")


class _PhoneNumberModel(CustomBaseModel):
country_code: Optional[int] = Field(alias="countryCode")
phone_number: Optional[int] = Field(alias="phoneNumber")
phone_verified: Optional[bool] = Field(alias="phoneVerified")
country_code: Optional[int] = Field(None, alias="countryCode")
phone_number: Optional[int] = Field(None, alias="phoneNumber")
phone_verified: Optional[bool] = Field(None, alias="phoneVerified")
verification_date: Optional[datetime] = Field("verificationDate")


class _CustomerModel(CustomBaseModel):
account_status: Optional[str] = Field(alias="accountStatus")
account_status: Optional[str] = Field(None, alias="accountStatus")
additional_attributes: Optional[_AdditionalAttributesModel] = Field(
alias="additionalAttributes"
None, alias="additionalAttributes"
)
create_date: Optional[datetime] = Field(alias="createDate")
create_source: Optional[str] = Field(alias="createSource")
customer_type: Optional[str] = Field(alias="customerType")
emails: Optional[List[_EmailModel]]
first_name: Optional[str] = Field(alias="firstName")
forge_rock_id: Optional[UUID] = Field(alias="forgerockId")
guid: Optional[UUID]
is_cp_migrated: Optional[bool] = Field(alias="isCpMigrated")
lastname: Optional[str] = Field(alias="lastName")
create_date: Optional[datetime] = Field(None, alias="createDate")
create_source: Optional[str] = Field(None, alias="createSource")
customer_type: Optional[str] = Field(None, alias="customerType")
emails: Optional[List[_EmailModel]] = None
first_name: Optional[str] = Field(None, alias="firstName")
forge_rock_id: Optional[UUID] = Field(None, alias="forgerockId")
guid: Optional[UUID] = None
is_cp_migrated: Optional[bool] = Field(None, alias="isCpMigrated")
lastname: Optional[str] = Field(None, alias="lastName")
last_update_date: Optional[datetime] = Field("lastUpdateDate")
last_update_source: Optional[str] = Field("lastUpdateSource")
phone_numbers: Optional[List[_PhoneNumberModel]] = Field(alias="phoneNumbers")
preferred_language: Optional[str] = Field(alias="preferredLanguage")
signup_type: Optional[str] = Field(alias="signupType")
ui_language: Optional[str] = Field(alias="uiLanguage")
phone_numbers: Optional[List[_PhoneNumberModel]] = Field(None, alias="phoneNumbers")
preferred_language: Optional[str] = Field(None, alias="preferredLanguage")
signup_type: Optional[str] = Field(None, alias="signupType")
ui_language: Optional[str] = Field(None, alias="uiLanguage")


class AccountModel(CustomBaseModel):
Expand All @@ -64,7 +64,7 @@ class AccountModel(CustomBaseModel):

"""

customer: Optional[_CustomerModel]
customer: Optional[_CustomerModel] = None


class AccountResponseModel(StatusModel):
Expand Down
8 changes: 4 additions & 4 deletions mytoyota/models/endpoints/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class UnitValueModel(CustomBaseModel):


class _MessageModel(CustomBaseModel):
description: Optional[str]
description: Optional[str] = None
detailed_description: Optional[str] = Field(alias="detailedDescription", default=None)
response_code: Optional[str] = Field(alias="responseCode")
response_code: Optional[str] = Field(None, alias="responseCode")


class _MessagesModel(CustomBaseModel):
messages: Optional[List[_MessageModel]]
messages: Optional[List[_MessageModel]] = None


class StatusModel(CustomBaseModel):
Expand All @@ -45,7 +45,7 @@ class StatusModel(CustomBaseModel):

"""

status: Optional[Union[str, _MessagesModel]]
status: Optional[Union[str, _MessagesModel]] = None
code: Optional[int] = None
errors: Optional[List] = None
message: Optional[str] = None
10 changes: 5 additions & 5 deletions mytoyota/models/endpoints/electric.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ class ElectricStatusModel(CustomBaseModel):

"""

battery_level: Optional[int] = Field(alias="batteryLevel")
battery_level: Optional[int] = Field(None, alias="batteryLevel")
can_set_next_charging_event: Optional[bool] = Field(
alias="canSetNextChargingEvent", default=None
)
charging_status: Optional[str] = Field(alias="chargingStatus")
ev_range: Optional[UnitValueModel] = Field(alias="evRange")
ev_range_with_ac: Optional[UnitValueModel] = Field(alias="evRangeWithAc")
charging_status: Optional[str] = Field(None, alias="chargingStatus")
ev_range: Optional[UnitValueModel] = Field(None, alias="evRange")
ev_range_with_ac: Optional[UnitValueModel] = Field(None, alias="evRangeWithAc")
fuel_level: Optional[int] = Field(alias="fuelLevel", default=None)
fuel_range: Optional[UnitValueModel] = Field(alias="fuelRange", default=None)
last_update_timestamp: Optional[datetime] = Field(alias="lastUpdateTimestamp")
last_update_timestamp: Optional[datetime] = Field(None, alias="lastUpdateTimestamp")
remaining_charge_time: Optional[int] = Field(
alias="remainingChargeTime",
default=None,
Expand Down
8 changes: 4 additions & 4 deletions mytoyota/models/endpoints/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@


class _VehicleLocationModel(CustomBaseModel):
display_name: Optional[str] = Field(alias="displayName")
latitude: Optional[float]
location_acquisition_datetime: Optional[datetime] = Field(alias="locationAcquisitionDatetime")
longitude: Optional[float]
display_name: Optional[str] = Field(None, alias="displayName")
latitude: Optional[float] = None
location_acquisition_datetime: Optional[datetime] = Field(None, alias="locationAcquisitionDatetime")
longitude: Optional[float] = None


class LocationModel(CustomBaseModel):
Expand Down
26 changes: 13 additions & 13 deletions mytoyota/models/endpoints/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ class NotificationModel(CustomBaseModel):

"""

message_id: Optional[str] = Field(alias="messageId")
vin: Optional[str]
notification_date: Optional[datetime] = Field(alias="notificationDate")
is_read: Optional[bool] = Field(alias="isRead")
message_id: Optional[str] = Field(None, alias="messageId")
vin: Optional[str] = None
notification_date: Optional[datetime] = Field(None, alias="notificationDate")
is_read: Optional[bool] = Field(None, alias="isRead")
read_timestamp: Optional[datetime] = Field(alias="readTimestamp", default=None)
icon_url: Optional[str] = Field(alias="iconUrl")
message: Optional[str]
icon_url: Optional[str] = Field(None, alias="iconUrl")
message: Optional[str] = None
status: Optional[Union[int, str]] = None
type: Optional[str]
category: Optional[str]
display_category: Optional[str] = Field(alias="displayCategory")
type: Optional[str] = None
category: Optional[str] = None
display_category: Optional[str] = Field(None, alias="displayCategory")


class _PayloadItemModel(CustomBaseModel):
vin: Optional[str] = None
notifications: Optional[List[NotificationModel]]
notifications: Optional[List[NotificationModel]] = None


class NotificationResponseModel(CustomBaseModel):
Expand All @@ -64,7 +64,7 @@ class NotificationResponseModel(CustomBaseModel):
"""

guid: Optional[UUID] = None
status_code: Optional[int] = Field(alias="statusCode")
headers: Optional[_HeadersModel]
body: Optional[str]
status_code: Optional[int] = Field(None, alias="statusCode")
headers: Optional[_HeadersModel] = None
body: Optional[str] = None
payload: Optional[List[_PayloadItemModel]] = None
18 changes: 9 additions & 9 deletions mytoyota/models/endpoints/service_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class ServiceHistoryModel(CustomBaseModel):

"""

customer_created_record: Optional[bool] = Field(alias="customerCreatedRecord")
customer_created_record: Optional[bool] = Field(None, alias="customerCreatedRecord")
mileage: Optional[int] = None
notes: Any
operations_performed: Any = Field(alias="operationsPerformed")
ro_number: Any = Field(alias="roNumber")
service_category: Optional[str] = Field(alias="serviceCategory")
service_date: Optional[date] = Field(alias="serviceDate")
service_history_id: Optional[str] = Field(alias="serviceHistoryId")
service_provider: Optional[str] = Field(alias="serviceProvider")
servicing_dealer: Any = Field(alias="servicingDealer")
notes: Any = None
operations_performed: Any = Field(None, alias="operationsPerformed")
ro_number: Any = Field(None, alias="roNumber")
service_category: Optional[str] = Field(None, alias="serviceCategory")
service_date: Optional[date] = Field(None, alias="serviceDate")
service_history_id: Optional[str] = Field(None, alias="serviceHistoryId")
service_provider: Optional[str] = Field(None, alias="serviceProvider")
servicing_dealer: Any = Field(None, alias="servicingDealer")
unit: Optional[str] = None


Expand Down
30 changes: 15 additions & 15 deletions mytoyota/models/endpoints/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@


class _ValueStatusModel(CustomBaseModel):
value: Optional[str]
status: Optional[int]
value: Optional[str] = None
status: Optional[int] = None


class SectionModel(CustomBaseModel):
Expand All @@ -23,8 +23,8 @@ class SectionModel(CustomBaseModel):

"""

section: Optional[str]
values: Optional[List[_ValueStatusModel]]
section: Optional[str] = None
values: Optional[List[_ValueStatusModel]] = None


class VehicleStatusModel(CustomBaseModel):
Expand All @@ -39,15 +39,15 @@ class VehicleStatusModel(CustomBaseModel):

"""

category: Optional[str]
display_order: Optional[int] = Field(alias="displayOrder")
sections: Optional[List[SectionModel]]
category: Optional[str] = None
display_order: Optional[int] = Field(None, alias="displayOrder")
sections: Optional[List[SectionModel]] = None


class _TelemetryModel(CustomBaseModel):
fugage: Optional[UnitValueModel] = None
rage: Optional[UnitValueModel] = None
odo: Optional[UnitValueModel]
odo: Optional[UnitValueModel] = None


class RemoteStatusModel(CustomBaseModel):
Expand All @@ -65,13 +65,13 @@ class RemoteStatusModel(CustomBaseModel):

"""

vehicle_status: Optional[List[VehicleStatusModel]] = Field(alias="vehicleStatus")
telemetry: Optional[_TelemetryModel]
occurrence_date: Optional[datetime] = Field(alias="occurrenceDate")
caution_overall_count: Optional[int] = Field(alias="cautionOverallCount")
latitude: Optional[float]
longitude: Optional[float]
location_acquisition_datetime: Optional[datetime] = Field(alias="locationAcquisitionDatetime")
vehicle_status: Optional[List[VehicleStatusModel]] = Field(None, alias="vehicleStatus")
telemetry: Optional[_TelemetryModel] = None
occurrence_date: Optional[datetime] = Field(None, alias="occurrenceDate")
caution_overall_count: Optional[int] = Field(None, alias="cautionOverallCount")
latitude: Optional[float] = None
longitude: Optional[float] = None
location_acquisition_datetime: Optional[datetime] = Field(None, alias="locationAcquisitionDatetime")


class RemoteStatusResponseModel(StatusModel):
Expand Down
6 changes: 3 additions & 3 deletions mytoyota/models/endpoints/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class TelemetryModel(CustomBaseModel):

"""

fuel_type: Optional[str] = Field(alias="fuelType")
odometer: Optional[UnitValueModel]
fuel_type: Optional[str] = Field(None, alias="fuelType")
odometer: Optional[UnitValueModel] = None
fuel_level: Optional[int] = Field(alias="fuelLevel", default=None)
distance_to_empty: Optional[UnitValueModel] = Field(alias="distanceToEmpty", default=None)
timestamp: Optional[datetime]
timestamp: Optional[datetime] = None


class TelemetryResponseModel(StatusModel):
Expand Down
Loading