Skip to content

Commit

Permalink
Update pydantic to 2.x and use compatibility layer
Browse files Browse the repository at this point in the history
Use v2's compatibility layer for a simple upgrade path
for now.
  • Loading branch information
deejay1 committed Jan 10, 2025
1 parent 10c2a88 commit 39a47e8
Show file tree
Hide file tree
Showing 14 changed files with 485 additions and 375 deletions.
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import List, Optional
from uuid import UUID

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel
from mytoyota.utils.models import CustomBaseModel
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Toyota Connected Services API - Common Endpoint Models."""
from typing import List, Optional, Union

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.utils.models import CustomBaseModel

Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/electric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime
from typing import Optional

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel, UnitValueModel
from mytoyota.utils.models import CustomBaseModel
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime
from typing import Optional

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel
from mytoyota.utils.models import CustomBaseModel
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import List, Optional, Union
from uuid import UUID

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.utils.models import CustomBaseModel

Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/service_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import date
from typing import Any, List, Optional

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel
from mytoyota.utils.models import CustomBaseModel
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime
from typing import List, Optional

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel, UnitValueModel
from mytoyota.utils.models import CustomBaseModel
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime
from typing import Optional

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel, UnitValueModel
from mytoyota.utils.models import CustomBaseModel
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/trips.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any, List, Optional
from uuid import UUID

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel
from mytoyota.utils.helpers import add_with_none
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/vehicle_guid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel
from mytoyota.utils.models import CustomBaseModel
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/vehicle_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime
from typing import Any, List, Optional

from pydantic import Field
from pydantic.v1 import Field

from mytoyota.models.endpoints.common import StatusModel
from mytoyota.utils.models import CustomBaseModel
Expand Down
2 changes: 1 addition & 1 deletion mytoyota/utils/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Utilities for manipulating or extend pydantic models."""
from pydantic import BaseModel, root_validator
from pydantic.v1 import BaseModel, root_validator


class CustomBaseModel(BaseModel):
Expand Down
662 changes: 386 additions & 276 deletions poetry.lock

Large diffs are not rendered by default.

174 changes: 87 additions & 87 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
[tool.poetry]
name = "mytoyota"
description = "Python client for Toyota Connected Services."
authors = ["Simon Grud Hansen <[email protected]>"]
license = "MIT"
readme = "README.md"
version = "0.0.0"
packages = [
{include = "mytoyota"},
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
keywords = [
"Toyota",
"Car",
"MYT",
]
homepage = "https://github.com/DurgNomis-drol/mytoyota"
repository = "https://github.com/DurgNomis-drol/mytoyota"

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/DurgNomis-drol/mytoyota/issues"
"Release Notes" = "https://github.com/DurgNomis-drol/mytoyota/releases"

[tool.poetry.dependencies]
python = "^3.9"
langcodes = "^3.1"
httpx = ">=0.18.1"
arrow = "^1.1"
importlib-metadata = "^7.0.1"
pyjwt = "^2.8.0"
pydantic = "^1.10.0"
hishel = "^0.0.19"

[tool.poetry.dev-dependencies]
pre-commit = "^3.0.0"
pre-commit-hooks = "^4.5.0"
ruff = "^0.1.9"
codespell = "^2.0.0"
pytest = "^7.2.0"
pytest-pretty = "^1.2.0"
pytest-asyncio = "^0.21.1"
pytest-httpx = "^0.28.0"

[tool.ruff]
select = [
# Ruff specific
"RUF",
# Pylint
"PL",
# Pyflakes
"F",
# pep8-naming
"N",
# Pycodestyle
"E",
"W",
"D",
# flake8-2020
"YTT",
# flake8-async
"ASYNC",
# flake8-bugbear
"B",
# flake8-unused-arguments
"ARG",
# flake8-commas
"COM",
# Isort
"I"
]
extend-ignore = ["PLR2004", "D203", "D213", "COM812"]
line-length = 99
fix = true

[tool.poetry-dynamic-versioning]
enable = true

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"
[tool.poetry]
name = "mytoyota"
description = "Python client for Toyota Connected Services."
authors = ["Simon Grud Hansen <[email protected]>"]
license = "MIT"
readme = "README.md"
version = "0.0.0"
packages = [
{include = "mytoyota"},
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
keywords = [
"Toyota",
"Car",
"MYT",
]
homepage = "https://github.com/DurgNomis-drol/mytoyota"
repository = "https://github.com/DurgNomis-drol/mytoyota"

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/DurgNomis-drol/mytoyota/issues"
"Release Notes" = "https://github.com/DurgNomis-drol/mytoyota/releases"

[tool.poetry.dependencies]
python = "^3.9"
langcodes = "^3.1"
httpx = ">=0.18.1"
arrow = "^1.1"
importlib-metadata = "^7.0.1"
pyjwt = "^2.8.0"
pydantic = "^2.10.5"
hishel = "^0.0.19"

[tool.poetry.dev-dependencies]
pre-commit = "^3.0.0"
pre-commit-hooks = "^4.5.0"
ruff = "^0.1.9"
codespell = "^2.0.0"
pytest = "^7.2.0"
pytest-pretty = "^1.2.0"
pytest-asyncio = "^0.21.1"
pytest-httpx = "^0.28.0"

[tool.ruff]
select = [
# Ruff specific
"RUF",
# Pylint
"PL",
# Pyflakes
"F",
# pep8-naming
"N",
# Pycodestyle
"E",
"W",
"D",
# flake8-2020
"YTT",
# flake8-async
"ASYNC",
# flake8-bugbear
"B",
# flake8-unused-arguments
"ARG",
# flake8-commas
"COM",
# Isort
"I"
]
extend-ignore = ["PLR2004", "D203", "D213", "COM812"]
line-length = 99
fix = true

[tool.poetry-dynamic-versioning]
enable = true

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"

0 comments on commit 39a47e8

Please sign in to comment.