Skip to content

[REFACTOR] Delete annex, fix last docformat issues, enable docformat check in make check - #629

Open
Victor Schappert (vcschapp) wants to merge 3 commits into
mainfrom
ppa
Open

[REFACTOR] Delete annex, fix last docformat issues, enable docformat check in make check#629
Victor Schappert (vcschapp) wants to merge 3 commits into
mainfrom
ppa

Conversation

@vcschapp

@vcschapp Victor Schappert (vcschapp) commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Description

This is the last-but-one polish/refactor commit planned for the Pydantic packages before we start publishing them to PyPI.

In this PR:

  • The package overture-schema-annex is temporarily removed as discussed with stepps in #wg-schema on 7/30.
  • Two CLI bugs discovered as a result of deleting overture-schema-annex are fixed and unit tests are added to regression test both the before and after scenarios.
  • The remaining straggling make docformat errors are fixed.
  • The make docformat check is turn on as part of make check validation.

The only thing I anticipate changing after this PR is merged is enacting the decision from the 2026-03-11 / CODING SESH 💻:

Agreed to rename overture-schema-<theme>-theme to overture-schema-theme-<theme>

Merge guidance: Rebase

All three commits are independently valuable, so this PR should be squash-merged.

Journey

Testing

make check passes (lint, mypy, doctest, and the full test suite). JSON Schema baselines were regenerated to reflect the reconciled model.

Documentation website

[Docs preview for this PR.](https://dfhx9f55j8eg5.cloudfront.net/pr/<PUT THE PR # HERE>)

Related issues

Closes #617.

@vcschapp Victor Schappert (vcschapp) changed the title [REFACTOR][DOCS][CHORE] Delete annex, fix last docformat issues, enable docformat check in make check [REFACTOR] Delete annex, fix last docformat issues, enable docformat check in make check Jul 31, 2026
Signed-off-by: schapper <schapper@amazon.com>
Removing the annex package's `Sources` model left the discovered model
union without its last plain (non-discriminated) member, changing
pydantic's validation output and exposing two latent bugs in the
`overture-schema-cli` error formatter:

1. False "Ambiguous" warning on a clean match: when validating a list
   against a union that mixes a tagged-union with another discriminated
   member†, an item that cleanly matched one branch still emitted a
   `union_tag_not_found` error from the sibling branch. That empty
   discriminator path error formed a group that tied with the real
   match, so the CLI wrongly reported "Ambiguous: data matches multiple
   types equally." Fixed by discarding sibling-branch `union_tag_not_found`
   noise for any item that already has a concrete error, before tie
   detection.

2. Opaque message for undiscriminatable items: an item matching no
   discriminator (e.g. missing `type`) produced only "Unable to extract
   tag using discriminator" with no field-level detail‡. Fixed by
   re-validating such an item against each candidate model, selecting the
   best fit (fewest errors), and surfacing that model's field-level errors
   under the item's index.

-----------

† Simplified example of "validating a list against a union that mixes a
  tagged union with another discriminated member:

```python
from typing import Literal
from pydantic import BaseModel, TypeAdapter

class Building(BaseModel):
    type: Literal["building"]
    id: str

class Place(BaseModel):
    type: Literal["place"]
    id: str

Feature = Building | Place            # the UNION
adapter = TypeAdapter(list[Feature])  # a LIST of that union

adapter.validate_python([
    {"type": "building", "id": "b1"},  # element 0 → must be one of {Building, Place} → Building
    {"type": "place",    "id": "p1"},  # element 1 → must be one of {Building, Place} → Place
])
```

The CLI basically does this against an input JSON array of features.

-----------

‡ Here's a trivial example of the second situation:

```python
from typing import Annotated, Literal, Union
from pydantic import BaseModel, Field, TypeAdapter, ValidationError

class Building(BaseModel):
    type: Literal["building"]

class Place(BaseModel):
    type: Literal["place"]

Feature = Annotated[Union[Building, Place], Field(discriminator="type")]
adapter = TypeAdapter(list[Feature])

adapter.validate_python([{}, {}])
```

Signed-off-by: schapper <schapper@amazon.com>
Signed-off-by: schapper <schapper@amazon.com>
@github-actions

Copy link
Copy Markdown

🗺️ Schema reference docs preview is live!

🌍 Preview https://staging.overturemaps.org/schema/pr/629/schema/index.html
🕐 Updated Jul 31, 2026 23:18 UTC
📝 Commit 2ac5e36
🔧 env SCHEMA_PREVIEW true

Note

♻️ This preview updates automatically with each push to this PR.

@vcschapp

Copy link
Copy Markdown
Collaborator Author

Seth Fitzsimmons (@sethfitz) IMO it's preferable to ship this one rather than #619.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] Drop overture-schema-annex package before Pydantic schema GA

2 participants