Skip to content
Open
Changes from all commits
Commits
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
35 changes: 12 additions & 23 deletions packages/overture-schema-core/src/overture/schema/core/models.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
import textwrap
from typing import Annotated, Generic, TypeVar

from pydantic import (
BaseModel,
ConfigDict,
Field,
GetJsonSchemaHandler,
model_validator,
)
from pydantic.json_schema import JsonSchemaValue
from pydantic_core import core_schema
from typing_extensions import Self

from overture.schema.system.feature import Feature
from overture.schema.system.field_constraint import UniqueItemsConstraint
from overture.schema.system.model_constraint import no_extra_fields
from overture.schema.system.primitive import (
Geometry,
)
from overture.schema.system.primitive import BBox, Geometry
from overture.schema.system.ref import Id, Identified
from overture.schema.system.string import (
CountryCodeAlpha2,
)
from overture.schema.system.string import CountryCodeAlpha2
from pydantic import BaseModel, ConfigDict, Field, GetJsonSchemaHandler, model_validator
from pydantic.json_schema import JsonSchemaValue
Comment on lines +7 to +11
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import grouping/order here appears to violate the repo’s Ruff isort convention (third-party imports before first-party). In other core modules (e.g., packages/overture-schema-core/src/overture/schema/core/cartography.py:5-12), pydantic is imported before overture.*. Reorder these imports into stdlib / third-party / first-party blocks to avoid ruff (I001) failures.

Copilot uses AI. Check for mistakes.
from pydantic_core import core_schema
from typing_extensions import Self

from .enums import PerspectiveMode
from .sources import Sources
from .types import (
FeatureVersion,
Level,
)
from .types import FeatureVersion, Level

ThemeT = TypeVar("ThemeT", bound=str)
TypeT = TypeVar("TypeT", bound=str)
Expand All @@ -49,6 +35,7 @@ class OvertureFeature(Identified, Feature, Generic[ThemeT, TypeT]):
# this is an enum in the JSON Schema, but that prevents OvertureFeature from being extended
type: TypeT
geometry: Geometry
bbox: BBox
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bbox is being overridden here as a required BBox, which changes the GeoJSON/Feature contract and conflicts with Feature.bbox being optional (packages/overture-schema-system/src/overture/schema/system/feature.py:198-205). This will also break existing construction/validation paths that omit bbox (e.g., GeoJSON without a bbox). If bbox is meant to remain optional, remove this override and inherit the field from Feature, or type it as Omitable[BBox] (or BBox | None with an appropriate default) and keep the Field description consistent with Feature.

Suggested change
bbox: BBox

Copilot uses AI. Check for mistakes.
version: FeatureVersion

# Optional
Expand Down Expand Up @@ -86,12 +73,14 @@ def __get_pydantic_json_schema__(
properties_object_schema = json_schema["properties"]["properties"]
properties_object_schema["patternProperties"] = {
"^ext_.*$": {
"description": textwrap.dedent("""
"description": textwrap.dedent(
"""
Additional top-level properties are allowed if prefixed by `ext_`.

This feature is a on a deprecation path and will be removed once the schema is
fully migrated to Pydantic.
""").strip(),
"""
).strip(),
}
}
properties_object_schema["additionalProperties"] = False
Expand Down
Loading