Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4175250
wip - repackage/modularize
vcschapp Sep 30, 2025
4320c1f
wip - merge to pydantic main, making a huge mess along the way
vcschapp Oct 1, 2025
c3dbf6f
wip - move bbox
vcschapp Oct 1, 2025
0e2d001
wip - move primitive numeric types
vcschapp Oct 1, 2025
16a1f4b
wip - Document numeric primitives and add missing `int16`
vcschapp Oct 1, 2025
41ae7aa
wip - replace LR base types with pct, but not done for Confidence yet
vcschapp Oct 1, 2025
d2c4b5f
wip - Migrate basic constraint, collection constraints
vcschapp Oct 1, 2025
d06c41e
wip - Consistency: Rename WhitespaceConstraint -> StrippedConstraint …
vcschapp Oct 1, 2025
dcb73d8
wip - Migrate string types/constraints out of validation package
vcschapp Oct 1, 2025
b154fa0
wip - Add TypeAlias to quiet Pylance warnings
vcschapp Oct 1, 2025
76c617a
wip - add unmodeled dependencies
vcschapp Oct 2, 2025
ca9a048
wip - Add pdoc and slightly modify foundation to make it pdoc friendly
vcschapp Oct 2, 2025
b8c14ac
wip - fix doctests and run them as part of `make check`
vcschapp Oct 2, 2025
3ef76af
add make target for docs format checking but don't make it mandatory …
vcschapp Oct 2, 2025
53428d0
wip - CHECKS FAILING NOW - make mypy target work on parameterized pac…
vcschapp Oct 2, 2025
5a74b04
wip - Fix broken mypy checks in foundation package
vcschapp Oct 2, 2025
520f322
wip - Rename 'foundation' package to 'system' to avoid OMF "Foundatio…
vcschapp Oct 2, 2025
7da3ea4
wip - Remove GERS stuff from diff
vcschapp Oct 3, 2025
66a6c65
wip - PR comment on 397 - fix `sed` pattern
vcschapp Oct 3, 2025
f202c57
wip - cherrypick back the changes from #394, eeeep
vcschapp Oct 3, 2025
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
33 changes: 21 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.PHONY: default uv-sync check test-all test mypy reset-baseline-schemas
.PHONY: default uv-sync check test-all test docformat doctest mypy reset-baseline-schemas

default: test-all

uv-sync:
@uv sync --all-packages

check: test uv-sync
check: test doctest
@uv run ruff check -q packages/
@$(MAKE) mypy
@uv run ruff format --check packages/
Expand All @@ -16,18 +16,27 @@ test-all: uv-sync
test: uv-sync
@uv run pytest packages/ -x

docformat:
@find packages/*/src -name "*.py" -type f -not -name "__*" \
| xargs uv run pydocstyle --convention=numpy --add-ignore=D105
Comment thread
vcschapp marked this conversation as resolved.

doctest: uv-sync
@# $$ escapes $ for make - sed needs literal $ for end-of-line anchor
@find packages/*/src -name "*.py" -type f -not -name "__*" \
| sed 's|^packages/[^/]*/src/||' \
| sed 's|/|.|g' \
| sed 's|\.py$$||' \
| xargs uv run python -c 'import doctest, importlib, sys; [doctest.testmod(importlib.import_module(m)) for m in sys.argv[1:]]'

# mypy type checking with namespace package support
mypy: uv-sync
@cd packages && uv run mypy --no-error-summary --namespace-packages \
-p overture.schema \
-p overture.schema.addresses \
-p overture.schema.base \
-p overture.schema.buildings \
-p overture.schema.core \
-p overture.schema.divisions \
-p overture.schema.places \
-p overture.schema.transportation \
-p overture.schema.validation
@# $$ escapes $ for make - sed needs literal $ for end-of-line anchor
@find packages -maxdepth 1 -type d -name "overture-schema*" \
| sort \
| sed 's|-theme$$||' \
| tr - . \
| sed 's|^packages/|-p |' \
| xargs uv run mypy --no-error-summary
Comment thread
sethfitz marked this conversation as resolved.
@uv run mypy --no-error-summary packages/*/tests/*.py

reset-baseline-schemas:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
Feature,
StrictBaseModel,
)
from overture.schema.core.geometry import (
from overture.schema.core.types import CountryCode
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)
from overture.schema.core.types import CountryCode, TrimmedString
from overture.schema.system.string import StrippedString
Comment thread
vcschapp marked this conversation as resolved.


class AddressLevel(StrictBaseModel):
Expand All @@ -26,7 +27,7 @@ class AddressLevel(StrictBaseModel):
"""

value: Annotated[
TrimmedString | None,
StrippedString | None,
Field(
min_length=1,
),
Expand Down Expand Up @@ -67,14 +68,14 @@ class Address(Feature[Literal["addresses"], Literal["address"]]):
] = None
country: CountryCode | None = None
number: Annotated[
TrimmedString | None,
StrippedString | None,
Field(
min_length=1,
description="""The house number for this address. This field may not strictly be a number. Values such as "74B", "189 1/2", "208.5" are common as the number part of an address and they are not part of the "unit" of this address.""",
),
] = None
postal_city: Annotated[
TrimmedString | None,
StrippedString | None,
Field(
min_length=1,
description="""In some countries or regions, a mailing address may need to specify a different city name than the city that actually contains the address coordinates. This optional field can be used to specify the alternate city name to use.
Expand All @@ -87,21 +88,21 @@ class Address(Feature[Literal["addresses"], Literal["address"]]):
),
] = None
postcode: Annotated[
TrimmedString | None,
StrippedString | None,
Field(
min_length=1,
description="The postcode for the address",
),
] = None
street: Annotated[
TrimmedString | None,
StrippedString | None,
Field(
min_length=1,
description="""The street name associated with this address. The street name can include the street "type" or street suffix, e.g., Main Street. Ideally this is fully spelled out and not abbreviated but we acknowledge that many address datasets abbreviate the street name so it is acceptable.""",
),
] = None
unit: Annotated[
TrimmedString | None,
StrippedString | None,
Field(
min_length=1,
description="The suite/unit/apartment/floor number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
from overture.schema.core import (
Feature,
)
from overture.schema.core.geometry import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.core.models import CartographicallyHinted
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)


class Bathymetry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
from overture.schema.core import (
Feature,
)
from overture.schema.core.geometry import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.core.models import Named, Stacked
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)

from ..enums import SurfaceMaterial

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
from overture.schema.core import (
Feature,
)
from overture.schema.core.geometry import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.core.models import Named, Stacked
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)

from ..enums import SurfaceMaterial

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
from overture.schema.core import (
Feature,
)
from overture.schema.core.geometry import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.core.models import CartographicallyHinted
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)


class LandCover(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
from overture.schema.core import (
Feature,
)
from overture.schema.core.geometry import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.core.models import Named, Stacked
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)

from ..enums import SurfaceMaterial

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic import BaseModel

from overture.schema.base.types import SourceTags
from overture.schema.core.types import WikidataId
from overture.schema.system.string import WikidataId


class SourcedFromOpenStreetMap(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import Field

from overture.schema.core.primitives import float64, int32
from overture.schema.system.primitive import float64, int32

Elevation = NewType(
"Elevation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
from overture.schema.core import (
Feature,
)
from overture.schema.core.geometry import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.core.models import Named, Stacked
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)


class Water(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
from pydantic import ConfigDict, Field

from overture.schema.core import Feature
from overture.schema.core.geometry import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.core.models import Named, Stacked
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)

from ..models import Shape
from .enums import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
from pydantic import Field

from overture.schema.core import Feature
from overture.schema.core.geometry import Geometry, GeometryType, GeometryTypeConstraint
from overture.schema.core.models import Named, Stacked
from overture.schema.core.ref import Reference, Relationship
from overture.schema.core.types import Id
from overture.schema.system.primitive import (
Geometry,
GeometryType,
GeometryTypeConstraint,
)

from ..building.models import Building
from ..models import Shape
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
RoofOrientation,
RoofShape,
)
from overture.schema.core.primitives import float64, int32
from overture.schema.core.types import HexColor
from overture.schema.system.primitive import float64, int32
from overture.schema.system.string import HexColor


class Shape(BaseModel):
Expand Down
25 changes: 15 additions & 10 deletions packages/overture-schema-core/src/overture/schema/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,37 @@
)
from pydantic_core import core_schema

from overture.schema.core.bbox import BBox
from overture.schema.system.constraint import UniqueItemsConstraint
from overture.schema.system.primitive import (
BBox,
Geometry,
)
from overture.schema.system.string import (
JsonPointer,
LanguageTag,
RegionCode,
StrippedString,
)
from overture.schema.validation import (
allow_extension_fields,
)

from .enums import NameVariant, PerspectiveMode, Side
from .geometry import Geometry
from .types import (
CommonNames,
ConfidenceScore,
CountryCode,
FeatureUpdateTime,
FeatureVersion,
Id,
JsonPointer,
LanguageTag,
Level,
LinearlyReferencedRange,
MaxZoom,
MinZoom,
Prominence,
RegionCode,
SortKey,
TrimmedString,
)
from .validation import ConstraintValidatedModel, UniqueItemsConstraint
from .validation import ConstraintValidatedModel


class StrictBaseModel(BaseModel):
Expand Down Expand Up @@ -96,7 +101,7 @@ class SourcePropertyItem(GeometricRangeScope):
# Optional

license: Annotated[
TrimmedString | None,
StrippedString | None,
Field(
description="License name. This should be a valid SPDX license identifier when available. If the license is NULL, contact the data provider for more license information.",
),
Expand Down Expand Up @@ -264,7 +269,7 @@ class NameRule(GeometricRangeScope, SideScope):

# Required

value: Annotated[TrimmedString, Field(min_length=1)]
value: Annotated[StrippedString, Field(min_length=1)]
variant: NameVariant

# Optional
Expand All @@ -287,7 +292,7 @@ class Names(StrictBaseModel):
# Required

primary: Annotated[
TrimmedString, Field(min_length=1, description="The most commonly used name.")
StrippedString, Field(min_length=1, description="The most commonly used name.")
]

# Optional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +0,0 @@
"""Primitive data types.
Comment thread
vcschapp marked this conversation as resolved.

This module provides additional, more specific primitive types that come with automatic
constraint validation and are intended to support multi-target serialization support
(where the list of and names for these types vary).
"""

from .numeric import (
float32,
float64,
int8,
int32,
int64,
uint8,
uint16,
uint32,
)

__all__ = [
"uint8",
"uint16",
"uint32",
"int8",
"int32",
"int64",
"float32",
"float64",
]

This file was deleted.

4 changes: 2 additions & 2 deletions packages/overture-schema-core/src/overture/schema/core/ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class that is said to "hold the reference") and the relatee.
>>> from overture.schema.core.ref import Reference, Relationship
>>> from overture.schema.core.types import Id
>>> class Park(Feature):
>>> pass
... pass
>>> class ParkBench(Feature):
>>> park_id: Annotated[Id, Reference(Relationship.BELONGS_TO, Park)]
... park_id: Annotated[Id, Reference(Relationship.BELONGS_TO, Park)]
"""

relationship: Relationship
Expand Down
Loading