[Pydantic] housekeeping - #390
Merged
Merged
Conversation
Seth Fitzsimmons (sethfitz)
requested a review
from Jennings Anderson (jenningsanderson)
September 11, 2025 22:02
Seth Fitzsimmons (sethfitz)
temporarily deployed
to
staging
September 11, 2025 22:02 — with
GitHub Actions
Inactive
Jennings Anderson (jenningsanderson)
approved these changes
Sep 12, 2025
Data for bathymetry, land cover, and segment types do not contain `levels` columns, despite the JSON Schema claiming that they should. This syncs the models with the data we distribute.
The same effect can be achieved by annotating a dict where the key contains a pattern constraint with a Field specifying json_schema_extra.
Seth Fitzsimmons (sethfitz)
force-pushed
the
pydantic-cleanup
branch
from
September 12, 2025 17:56
43300bf to
6667e00
Compare
Seth Fitzsimmons (sethfitz)
temporarily deployed
to
staging
September 12, 2025 17:56 — with
GitHub Actions
Inactive
Seth Fitzsimmons (sethfitz)
requested a review
from Jennings Anderson (jenningsanderson)
September 12, 2025 17:56
Jennings Anderson (jenningsanderson)
approved these changes
Sep 12, 2025
Jennings Anderson (jenningsanderson)
left a comment
Collaborator
There was a problem hiding this comment.
🧹 Looks like the linter got a hold of this one!
Victor Schappert (vcschapp)
added a commit
that referenced
this pull request
Jul 24, 2026
This commit organizes the transportation Pydantic package to align with the other theme packages already done: addresses, base, buildings, divisions, and places. Transportation was the last theme still using the old layout, so with this commit the whole theme set is organized consistently. Organization work done: 1. Each feature type gets its own main module. `connector` becomes a flat `connector.py`, but because `segment` is a discriminated union over road, rail, and water subtypes, `segment` becomes a *package* with one module per subtype (`road.py`, `rail.py`, `water.py`) plus a private `_common.py` for the shared base. This is the one place we do NOT eliminate a sub-directory (unlike divisions): the subtype union makes a package the natural fit. 2. Types used exclusively by one subtype move into that subtype's module and are renamed to be subtype-scoped: `Subtype` -> `SegmentSubtype`, `Subclass` -> `RoadSubclass`, `SubclassRule` -> `RoadSubclassRule`, `SurfaceRule` -> `RoadSurfaceRule`, `AccessRestrictionRule` -> `AccessRule`, `SequenceEntry` -> `ProhibitedTransitionSequenceEntry`. Exception (deliberate): the mode-independent rule types currently used only by road but conceivably reusable by other subtypes (the prohibited-transition, speed, and width types) are kept in `_common.py`. 3. Eliminated the old flat `enums.py`, `models.py`, and `types.py`, and the `connector/` and `segment/` (models.py) sub-packages. 4. Curated `__all__` in both the theme `__init__.py` and the segment package's `__init__.py`. Relationships added: 1. `from_connector_id` and `to_connector_id` in `DestinationRule` (to `Connector`). 2. `to_segment_id` in `DestinationRule` (to `TransportationSegment`). 3. `connector_id` in `ProhibitedTransitionSequenceEntry` (to `Connector`). 4. `segment_id` in `ProhibitedTransitionSequenceEntry` (to `TransportationSegment`). Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to transportation. 2. Converted `SegmentSubtype` and `AccessType` to `DocumentedEnum` so they have a richer presence in the schema reference. (`RoadSurface` and `DestinationLabelType` are intentionally left as plain enums for now, as I don't have cycles to generate docs for them.) Schema reconciliation (a dimension the divisions refactor did not have): 1. Made `routes` and `subclass_rules` road-only (moved from the shared base to `RoadSegment`) and back-ported the change to the JSON Schema so both representations agree. While technically backwardly- incompatible, this fixes a error that dates back to the JSON Schema and that was never intended. 2. Removed the scalar `level` from segment in both the Pydantic model and the JSON Schema, finishing the model/schema sync begun in "Remove levels from types without data for them" (commit dd5d3f2, PR #390), which updated the model but left `level` on the legacy JSON Schema, leading to a discrepancy between schemas. Signed-off-by: schapper <schapper@amazon.com>
Victor Schappert (vcschapp)
added a commit
that referenced
this pull request
Jul 28, 2026
This commit organizes the transportation Pydantic package to align with the other theme packages already done: addresses, base, buildings, divisions, and places. Transportation was the last theme still using the old layout, so with this commit the whole theme set is organized consistently. Organization work done: 1. Each feature type gets its own main module. `connector` becomes a flat `connector.py`, but because `segment` is a discriminated union over road, rail, and water subtypes, `segment` becomes a *package* with one module per subtype (`road.py`, `rail.py`, `water.py`) plus a private `_common.py` for the shared base. This is the one place we do NOT eliminate a sub-directory (unlike divisions): the subtype union makes a package the natural fit. 2. Types used exclusively by one subtype move into that subtype's module and are renamed to be subtype-scoped: `Subtype` -> `SegmentSubtype`, `Subclass` -> `RoadSubclass`, `SubclassRule` -> `RoadSubclassRule`, `SurfaceRule` -> `RoadSurfaceRule`, `AccessRestrictionRule` -> `AccessRule`, `SequenceEntry` -> `ProhibitedTransitionSequenceEntry`. Exception (deliberate): the mode-independent rule types currently used only by road but conceivably reusable by other subtypes (the prohibited-transition, speed, and width types) are kept in `_common.py`. 3. Eliminated the old flat `enums.py`, `models.py`, and `types.py`, and the `connector/` and `segment/` (models.py) sub-packages. 4. Curated `__all__` in both the theme `__init__.py` and the segment package's `__init__.py`. Relationships added: 1. `from_connector_id` and `to_connector_id` in `DestinationRule` (to `Connector`). 2. `to_segment_id` in `DestinationRule` (to `TransportationSegment`). 3. `connector_id` in `ProhibitedTransitionSequenceEntry` (to `Connector`). 4. `segment_id` in `ProhibitedTransitionSequenceEntry` (to `TransportationSegment`). Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to transportation. 2. Converted `SegmentSubtype` and `AccessType` to `DocumentedEnum` so they have a richer presence in the schema reference. (`RoadSurface` and `DestinationLabelType` are intentionally left as plain enums for now, as I don't have cycles to generate docs for them.) Schema reconciliation (a dimension the divisions refactor did not have): 1. Made `routes` and `subclass_rules` road-only (moved from the shared base to `RoadSegment`) and back-ported the change to the JSON Schema so both representations agree. While technically backwardly- incompatible, this fixes a error that dates back to the JSON Schema and that was never intended. 2. Removed the scalar `level` from segment in both the Pydantic model and the JSON Schema, finishing the model/schema sync begun in "Remove levels from types without data for them" (commit dd5d3f2, PR #390), which updated the model but left `level` on the legacy JSON Schema, leading to a discrepancy between schemas. Signed-off-by: schapper <schapper@amazon.com>
Victor Schappert (vcschapp)
added a commit
that referenced
this pull request
Jul 28, 2026
This commit organizes the transportation Pydantic package to align with the other theme packages already done: addresses, base, buildings, divisions, and places. Transportation was the last theme still using the old layout, so with this commit the whole theme set is organized consistently. Organization work done: 1. Each feature type gets its own main module. `connector` becomes a flat `connector.py`, but because `segment` is a discriminated union over road, rail, and water subtypes, `segment` becomes a *package* with one module per subtype (`road.py`, `rail.py`, `water.py`) plus a private `_common.py` for the shared base. This is the one place we do NOT eliminate a sub-directory (unlike divisions): the subtype union makes a package the natural fit. 2. Types used exclusively by one subtype move into that subtype's module and are renamed to be subtype-scoped: `Subtype` -> `SegmentSubtype`, `Subclass` -> `RoadSubclass`, `SubclassRule` -> `RoadSubclassRule`, `SurfaceRule` -> `RoadSurfaceRule`, `AccessRestrictionRule` -> `AccessRule`, `SequenceEntry` -> `ProhibitedTransitionSequenceEntry`. Exception (deliberate): the mode-independent rule types currently used only by road but conceivably reusable by other subtypes (the prohibited-transition, speed, and width types) are kept in `_common.py`. 3. Eliminated the old flat `enums.py`, `models.py`, and `types.py`, and the `connector/` and `segment/` (models.py) sub-packages. 4. Curated `__all__` in both the theme `__init__.py` and the segment package's `__init__.py`. Relationships added: 1. `from_connector_id` and `to_connector_id` in `DestinationRule` (to `Connector`). 2. `to_segment_id` in `DestinationRule` (to `TransportationSegment`). 3. `connector_id` in `ProhibitedTransitionSequenceEntry` (to `Connector`). 4. `segment_id` in `ProhibitedTransitionSequenceEntry` (to `TransportationSegment`). Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to transportation. 2. Converted `SegmentSubtype` and `AccessType` to `DocumentedEnum` so they have a richer presence in the schema reference. (`RoadSurface` and `DestinationLabelType` are intentionally left as plain enums for now, as I don't have cycles to generate docs for them.) Schema reconciliation (a dimension the divisions refactor did not have): 1. Made `routes` and `subclass_rules` road-only (moved from the shared base to `RoadSegment`) and back-ported the change to the JSON Schema so both representations agree. While technically backwardly- incompatible, this fixes a error that dates back to the JSON Schema and that was never intended. 2. Removed the scalar `level` from segment in both the Pydantic model and the JSON Schema, finishing the model/schema sync begun in "Remove levels from types without data for them" (commit dd5d3f2, PR #390), which updated the model but left `level` on the legacy JSON Schema, leading to a discrepancy between schemas. Signed-off-by: schapper <schapper@amazon.com>
Victor Schappert (vcschapp)
added a commit
that referenced
this pull request
Jul 29, 2026
This commit organizes the transportation Pydantic package to align with the other theme packages already done: addresses, base, buildings, divisions, and places. Transportation was the last theme still using the old layout, so with this commit the whole theme set is organized consistently. Organization work done: 1. Each feature type gets its own main module. `connector` becomes a flat `connector.py`, but because `segment` is a discriminated union over road, rail, and water subtypes, `segment` becomes a *package* with one module per subtype (`road.py`, `rail.py`, `water.py`) plus a private `_common.py` for the shared base. This is the one place we do NOT eliminate a sub-directory (unlike divisions): the subtype union makes a package the natural fit. 2. Types used exclusively by one subtype move into that subtype's module and are renamed to be subtype-scoped: `Subtype` -> `SegmentSubtype`, `Subclass` -> `RoadSubclass`, `SubclassRule` -> `RoadSubclassRule`, `SurfaceRule` -> `RoadSurfaceRule`, `AccessRestrictionRule` -> `AccessRule`, `SequenceEntry` -> `ProhibitedTransitionSequenceEntry`. Exception (deliberate): the mode-independent rule types currently used only by road but conceivably reusable by other subtypes (the prohibited-transition, speed, and width types) are kept in `_common.py`. 3. Eliminated the old flat `enums.py`, `models.py`, and `types.py`, and the `connector/` and `segment/` (models.py) sub-packages. 4. Curated `__all__` in both the theme `__init__.py` and the segment package's `__init__.py`. Relationships added: 1. `from_connector_id` and `to_connector_id` in `DestinationRule` (to `Connector`). 2. `to_segment_id` in `DestinationRule` (to `TransportationSegment`). 3. `connector_id` in `ProhibitedTransitionSequenceEntry` (to `Connector`). 4. `segment_id` in `ProhibitedTransitionSequenceEntry` (to `TransportationSegment`). Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to transportation. 2. Converted `SegmentSubtype` and `AccessType` to `DocumentedEnum` so they have a richer presence in the schema reference. (`RoadSurface` and `DestinationLabelType` are intentionally left as plain enums for now, as I don't have cycles to generate docs for them.) Schema reconciliation (a dimension the divisions refactor did not have): 1. Made `routes` and `subclass_rules` road-only (moved from the shared base to `RoadSegment`) and back-ported the change to the JSON Schema so both representations agree. While technically backwardly- incompatible, this fixes a error that dates back to the JSON Schema and that was never intended. 2. Removed the scalar `level` from segment in both the Pydantic model and the JSON Schema, finishing the model/schema sync begun in "Remove levels from types without data for them" (commit dd5d3f2, PR #390), which updated the model but left `level` on the legacy JSON Schema, leading to a discrepancy between schemas. Signed-off-by: schapper <schapper@amazon.com>
Victor Schappert (vcschapp)
added a commit
that referenced
this pull request
Jul 29, 2026
This commit organizes the transportation Pydantic package to align with the other theme packages already done: addresses, base, buildings, divisions, and places. Transportation was the last theme still using the old layout, so with this commit the whole theme set is organized consistently. Organization work done: 1. Each feature type gets its own main module. `connector` becomes a flat `connector.py`, but because `segment` is a discriminated union over road, rail, and water subtypes, `segment` becomes a *package* with one module per subtype (`road.py`, `rail.py`, `water.py`) plus a private `_common.py` for the shared base. This is the one place we do NOT eliminate a sub-directory (unlike divisions): the subtype union makes a package the natural fit. 2. Types used exclusively by one subtype move into that subtype's module and are renamed to be subtype-scoped: `Subtype` -> `SegmentSubtype`, `Subclass` -> `RoadSubclass`, `SubclassRule` -> `RoadSubclassRule`, `SurfaceRule` -> `RoadSurfaceRule`, `AccessRestrictionRule` -> `AccessRule`, `SequenceEntry` -> `ProhibitedTransitionSequenceEntry`. Exception (deliberate): the mode-independent rule types currently used only by road but conceivably reusable by other subtypes (the prohibited-transition, speed, and width types) are kept in `_common.py`. 3. Eliminated the old flat `enums.py`, `models.py`, and `types.py`, and the `connector/` and `segment/` (models.py) sub-packages. 4. Curated `__all__` in both the theme `__init__.py` and the segment package's `__init__.py`. Relationships added: 1. `from_connector_id` and `to_connector_id` in `DestinationRule` (to `Connector`). 2. `to_segment_id` in `DestinationRule` (to `TransportationSegment`). 3. `connector_id` in `ProhibitedTransitionSequenceEntry` (to `Connector`). 4. `segment_id` in `ProhibitedTransitionSequenceEntry` (to `TransportationSegment`). Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to transportation. 2. Converted `SegmentSubtype` and `AccessType` to `DocumentedEnum` so they have a richer presence in the schema reference. (`RoadSurface` and `DestinationLabelType` are intentionally left as plain enums for now, as I don't have cycles to generate docs for them.) Schema reconciliation (a dimension the divisions refactor did not have): 1. Made `routes` and `subclass_rules` road-only (moved from the shared base to `RoadSegment`) and back-ported the change to the JSON Schema so both representations agree. While technically backwardly- incompatible, this fixes a error that dates back to the JSON Schema and that was never intended. 2. Removed the scalar `level` from segment in both the Pydantic model and the JSON Schema, finishing the model/schema sync begun in "Remove levels from types without data for them" (commit dd5d3f2, PR #390), which updated the model but left `level` on the legacy JSON Schema, leading to a discrepancy between schemas. Signed-off-by: schapper <schapper@amazon.com>
Victor Schappert (vcschapp)
added a commit
that referenced
this pull request
Jul 30, 2026
This commit organizes the transportation Pydantic package to align with the other theme packages already done: addresses, base, buildings, divisions, and places. Transportation was the last theme still using the old layout, so with this commit the whole theme set is organized consistently. Organization work done: 1. Each feature type gets its own main module. `connector` becomes a flat `connector.py`, but because `segment` is a discriminated union over road, rail, and water subtypes, `segment` becomes a *package* with one module per subtype (`road.py`, `rail.py`, `water.py`) plus a private `_common.py` for the shared base. This is the one place we do NOT eliminate a sub-directory (unlike divisions): the subtype union makes a package the natural fit. 2. Types used exclusively by one subtype move into that subtype's module and are renamed to be subtype-scoped: `Subtype` -> `SegmentSubtype`, `Subclass` -> `RoadSubclass`, `SubclassRule` -> `RoadSubclassRule`, `SurfaceRule` -> `RoadSurfaceRule`, `AccessRestrictionRule` -> `AccessRule`, `SequenceEntry` -> `ProhibitedTransitionSequenceEntry`. Exception (deliberate): the mode-independent rule types currently used only by road but conceivably reusable by other subtypes (the prohibited-transition, speed, and width types) are kept in `_common.py`. 3. Eliminated the old flat `enums.py`, `models.py`, and `types.py`, and the `connector/` and `segment/` (models.py) sub-packages. 4. Curated `__all__` in both the theme `__init__.py` and the segment package's `__init__.py`. Relationships added: 1. `from_connector_id` and `to_connector_id` in `DestinationRule` (to `Connector`). 2. `to_segment_id` in `DestinationRule` (to `TransportationSegment`). 3. `connector_id` in `ProhibitedTransitionSequenceEntry` (to `Connector`). 4. `segment_id` in `ProhibitedTransitionSequenceEntry` (to `TransportationSegment`). Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to transportation. 2. Converted `SegmentSubtype` and `AccessType` to `DocumentedEnum` so they have a richer presence in the schema reference. (`RoadSurface` and `DestinationLabelType` are intentionally left as plain enums for now, as I don't have cycles to generate docs for them.) Schema reconciliation (a dimension the divisions refactor did not have): 1. Made `routes` and `subclass_rules` road-only (moved from the shared base to `RoadSegment`) and back-ported the change to the JSON Schema so both representations agree. While technically backwardly- incompatible, this fixes a error that dates back to the JSON Schema and that was never intended. 2. Removed the scalar `level` from segment in both the Pydantic model and the JSON Schema, finishing the model/schema sync begun in "Remove levels from types without data for them" (commit dd5d3f2, PR #390), which updated the model but left `level` on the legacy JSON Schema, leading to a discrepancy between schemas. Signed-off-by: schapper <schapper@amazon.com>
Victor Schappert (vcschapp)
added a commit
that referenced
this pull request
Jul 30, 2026
This commit organizes the transportation Pydantic package to align with the other theme packages already done: addresses, base, buildings, divisions, and places. Transportation was the last theme still using the old layout, so with this commit the whole theme set is organized consistently. Organization work done: 1. Each feature type gets its own main module. `connector` becomes a flat `connector.py`, but because `segment` is a discriminated union over road, rail, and water subtypes, `segment` becomes a *package* with one module per subtype (`road.py`, `rail.py`, `water.py`) plus a private `_common.py` for the shared base. This is the one place we do NOT eliminate a sub-directory (unlike divisions): the subtype union makes a package the natural fit. 2. Types used exclusively by one subtype move into that subtype's module and are renamed to be subtype-scoped: `Subtype` -> `SegmentSubtype`, `Subclass` -> `RoadSubclass`, `SubclassRule` -> `RoadSubclassRule`, `SurfaceRule` -> `RoadSurfaceRule`, `AccessRestrictionRule` -> `AccessRule`, `SequenceEntry` -> `ProhibitedTransitionSequenceEntry`. Exception (deliberate): the mode-independent rule types currently used only by road but conceivably reusable by other subtypes (the prohibited-transition, speed, and width types) are kept in `_common.py`. 3. Eliminated the old flat `enums.py`, `models.py`, and `types.py`, and the `connector/` and `segment/` (models.py) sub-packages. 4. Curated `__all__` in both the theme `__init__.py` and the segment package's `__init__.py`. Relationships added: 1. `from_connector_id` and `to_connector_id` in `DestinationRule` (to `Connector`). 2. `to_segment_id` in `DestinationRule` (to `TransportationSegment`). 3. `connector_id` in `ProhibitedTransitionSequenceEntry` (to `Connector`). 4. `segment_id` in `ProhibitedTransitionSequenceEntry` (to `TransportationSegment`). Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to transportation. 2. Converted `SegmentSubtype` and `AccessType` to `DocumentedEnum` so they have a richer presence in the schema reference. (`RoadSurface` and `DestinationLabelType` are intentionally left as plain enums for now, as I don't have cycles to generate docs for them.) Schema reconciliation (a dimension the divisions refactor did not have): 1. Made `routes` and `subclass_rules` road-only (moved from the shared base to `RoadSegment`) and back-ported the change to the JSON Schema so both representations agree. While technically backwardly- incompatible, this fixes a error that dates back to the JSON Schema and that was never intended. 2. Removed the scalar `level` from segment in both the Pydantic model and the JSON Schema, finishing the model/schema sync begun in "Remove levels from types without data for them" (commit dd5d3f2, PR #390), which updated the model but left `level` on the legacy JSON Schema, leading to a discrepancy between schemas. Signed-off-by: schapper <schapper@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
levelsfrom types without data (columns) for them (bathymetry, land cover, segments)