Skip to content

Commit

Permalink
version bump geodense 0.0.1a4 + remove pydantic warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
arbakker committed Nov 29, 2023
1 parent 962f950 commit 23e5fe3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 41 deletions.
11 changes: 10 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
48 changes: 16 additions & 32 deletions src/coordinates_transformation_api/cityjson/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)$")]
Expand All @@ -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)$")]
Expand All @@ -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)$")]
Expand All @@ -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)$")]
Expand Down Expand Up @@ -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)$")]
Expand All @@ -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)$")]
Expand All @@ -337,8 +329,7 @@ class Type10(Enum):


class GeometryInstance(BaseModel):
class Config:
extra = "forbid"
model_config = ConfigDict(extra="forbid")

type: Type10
template: int
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -894,8 +879,7 @@ class TunnelInstallation(FieldAbstractCityObject):


class GeometryTemplates(BaseModel):
class Config:
extra = "forbid"
model_config = ConfigDict(extra="forbid")

templates: list[
MultiPoint
Expand Down
7 changes: 3 additions & 4 deletions src/coordinates_transformation_api/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from typing import Annotated, Any, Literal
from typing import Annotated, Any, Literal, Union

from pydantic import (
AfterValidator,
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/coordinates_transformation_api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 23e5fe3

Please sign in to comment.