diff --git a/.vscode/launch.json b/.vscode/launch.json index a3c2d44..7ed15d7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -22,6 +22,15 @@ }, "jinja": true, "justMyCode": false - } + }, + { + "name": "Python: Debug Tests", + "type": "python", + "request": "launch", + "program": "${file}", + "purpose": ["debug-test"], + "console": "integratedTerminal", + "justMyCode": false + } ] } diff --git a/README.md b/README.md index 4450996..11a1d9c 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,14 @@ Install enable pre-commit hook with: git config --local core.hooksPath .githooks ``` -To run debug session in VS Code install the package with `pip` with the +To run debug session in VS Code install the package with pip with the `--editable` flag: ```sh pip install --editable . ``` -Also install mypy as follows +Also install Mypy as follows ```sh mypy --install-types diff --git a/pyproject.toml b/pyproject.toml index 517a6bc..a9cb97a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dependencies = [ "pyproj == 3.6.0", "pydantic-settings == 2.0.2", "email-validator == 2.0.0", - "geodense@git+https://github.com/GeodetischeInfrastructuur/geodense@925a3ae377be64e784745850d78689702ed2cd69", + "geodense ~= 0.0.1a4", ] requires-python = ">=3.11.4" dynamic = ["version"] diff --git a/src/coordinates_transformation_api/cityjson/models.py b/src/coordinates_transformation_api/cityjson/models.py index f2bc480..ab40e36 100644 --- a/src/coordinates_transformation_api/cityjson/models.py +++ b/src/coordinates_transformation_api/cityjson/models.py @@ -11,7 +11,7 @@ from enum import Enum from typing import Annotated, Any, Union, cast -from pydantic import AnyUrl, BaseModel, EmailStr, Field, StringConstraints +from pydantic import AnyUrl, BaseModel, ConfigDict, EmailStr, Field, StringConstraints from pyproj import CRS from coordinates_transformation_api.crs_transform import get_transform_crs_fun @@ -35,8 +35,7 @@ class Extensions(BaseModel): class Transform(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") scale: list[float] = Field(..., max_length=3, min_length=3) translate: list[float] = Field(..., max_length=3, min_length=3) @@ -71,8 +70,7 @@ class Role(Enum): class ContactDetails(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") contactName: str phone: str | None = None @@ -204,8 +202,7 @@ class Texture1(BaseModel): class MultiSurface(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") type: Type3 lod: Annotated[str, StringConstraints(pattern=r"^(\d\.)(\d)$|^(\d)$")] @@ -220,8 +217,7 @@ class Type4(Enum): class CompositeSurface(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") type: Type4 lod: Annotated[str, StringConstraints(pattern=r"^(\d\.)(\d)$|^(\d)$")] @@ -245,8 +241,7 @@ class Texture3(BaseModel): class Solid(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") type: Type5 lod: Annotated[str, StringConstraints(pattern=r"^(\d\.)(\d)$|^(\d)$")] @@ -270,8 +265,7 @@ class Texture4(BaseModel): class CompositeSolid(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") type: Type6 lod: Annotated[str, StringConstraints(pattern=r"^(\d\.)(\d)$|^(\d)$")] @@ -302,8 +296,7 @@ class Semantics5(BaseModel): class MultiLineString(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") type: Type8 lod: Annotated[str, StringConstraints(pattern=r"^(\d\.)(\d)$|^(\d)$")] @@ -321,8 +314,7 @@ class Semantics6(BaseModel): class MultiSolid(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") type: Type9 lod: Annotated[str, StringConstraints(pattern=r"^(\d\.)(\d)$|^(\d)$")] @@ -337,8 +329,7 @@ class Type10(Enum): class GeometryInstance(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") type: Type10 template: int @@ -553,8 +544,7 @@ class Waterway(FieldAbstractTransportationComplex): class Material(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") name: str ambientIntensity: float | None = None @@ -586,8 +576,7 @@ class TextureType(Enum): class Texture(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") type: Type41 | None = None image: str | None = None @@ -597,8 +586,7 @@ class Config: class Appearance(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") default_theme_texture: str | None = Field(None, alias="default-theme-texture") default_theme_material: str | None = Field(None, alias="default-theme-material") @@ -608,8 +596,7 @@ class Config: class Metadata(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") identifier: str | None = None pointOfContact: ContactDetails | None = None @@ -628,9 +615,7 @@ class SemanticsModel(BaseModel): class MultiPoint(BaseModel): - class Config: - extra = "forbid" - + model_config = ConfigDict(extra="forbid") type: Type2 lod: Annotated[str, StringConstraints(pattern=r"^(\d\.)(\d)$|^(\d)$")] boundaries: list[int] @@ -894,8 +879,7 @@ class TunnelInstallation(FieldAbstractCityObject): class GeometryTemplates(BaseModel): - class Config: - extra = "forbid" + model_config = ConfigDict(extra="forbid") templates: list[ MultiPoint diff --git a/src/coordinates_transformation_api/settings.py b/src/coordinates_transformation_api/settings.py index 616500c..5cc3e4f 100644 --- a/src/coordinates_transformation_api/settings.py +++ b/src/coordinates_transformation_api/settings.py @@ -1,5 +1,5 @@ import json -from typing import Annotated, Any, Literal +from typing import Annotated, Any, Literal, Union from pydantic import ( AfterValidator, @@ -79,11 +79,10 @@ class AppSettings(BaseSettings): description="base url on wich the API is served", pattern=r"^((https?:\/\/)?[\w-]+(\.[\w-]+)*\.?(:\d+)?(\/\S*)?)", # adapted from https://codegolf.stackexchange.com/a/480 ) - cors_allow_origins: list[AnyHttpUrl] | CorsAllOrNone = Field( + cors_allow_origins: Union[list[AnyHttpUrl], CorsAllOrNone] = Field( alias="CORS_ALLOW_ORIGINS", - union_mode="left_to_right", default=None, - description="CORS origins", + description="CORS origins, either a comma separated list of HTTPS urls of the value `*` to allow CORS on all origins", ) @classmethod diff --git a/src/coordinates_transformation_api/util.py b/src/coordinates_transformation_api/util.py index 2f4e5b3..5910e5e 100644 --- a/src/coordinates_transformation_api/util.py +++ b/src/coordinates_transformation_api/util.py @@ -9,7 +9,6 @@ import yaml from fastapi import Request from fastapi.exceptions import RequestValidationError, ResponseValidationError - from geodense.geojson import CrsFeatureCollection from geodense.lib import ( # type: ignore # type: ignore THREE_DIMENSIONAL,