Skip to content

Commit

Permalink
update pydantic for breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Sep 28, 2023
1 parent e2c5332 commit 7eba5ef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ repos:
additional_dependencies:
- types-cachetools
- types-attrs
- pydantic~=2.0
- pydantic>=2.4
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"titiler.core>=0.14.0,<0.15",
"titiler.mosaic>=0.14.0,<0.15",
"geojson-pydantic~=1.0",
"pydantic~=2.0",
"pydantic>=2.4,<3.0",
"pydantic-settings~=2.0",
]
dynamic = ["version"]
Expand Down
12 changes: 3 additions & 9 deletions titiler/pgstac/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@

from geojson_pydantic.geometries import Geometry
from geojson_pydantic.types import BBox
from pydantic import (
BaseModel,
Field,
FieldValidationInfo,
field_validator,
model_validator,
)
from pydantic import BaseModel, Field, ValidationInfo, field_validator, model_validator
from typing_extensions import Annotated

from titiler.core.resources.enums import MediaType
Expand Down Expand Up @@ -95,7 +89,7 @@ def validate_datetime(cls, v):
return v

@field_validator("intersects")
def validate_spatial(cls, v: Optional[Geometry], info: FieldValidationInfo):
def validate_spatial(cls, v: Optional[Geometry], info: ValidationInfo):
"""Make sure bbox is not used with Intersects."""
if v and info.data["bbox"]:
raise ValueError("intersects and bbox parameters are mutually exclusive")
Expand Down Expand Up @@ -200,7 +194,7 @@ class Context(BaseModel):
matched: Optional[int] = None

@field_validator("limit")
def validate_limit(cls, v, info: FieldValidationInfo):
def validate_limit(cls, v, info: ValidationInfo):
"""validate limit."""
if info.data["returned"] > v:
raise ValueError(
Expand Down
4 changes: 2 additions & 2 deletions titiler/pgstac/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from pydantic import (
Field,
FieldValidationInfo,
PostgresDsn,
ValidationInfo,
field_validator,
model_validator,
)
Expand Down Expand Up @@ -68,7 +68,7 @@ class PostgresSettings(BaseSettings):
model_config = {"env_file": ".env", "extra": "ignore"}

@field_validator("database_url", mode="before")
def assemble_db_connection(cls, v: Optional[str], info: FieldValidationInfo) -> Any:
def assemble_db_connection(cls, v: Optional[str], info: ValidationInfo) -> Any:
"""Validate database config."""
if isinstance(v, str):
return v
Expand Down

0 comments on commit 7eba5ef

Please sign in to comment.