Skip to content

[Pydantic] housekeeping - #390

Merged
Seth Fitzsimmons (sethfitz) merged 6 commits into
pydanticfrom
pydantic-cleanup
Sep 12, 2025
Merged

[Pydantic] housekeeping#390
Seth Fitzsimmons (sethfitz) merged 6 commits into
pydanticfrom
pydantic-cleanup

Conversation

@sethfitz

Copy link
Copy Markdown
Collaborator
  • remove levels from types without data (columns) for them (bathymetry, land cover, segments)
  • fix typo

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🧹 Looks like the linter got a hold of this one!

@sethfitz
Seth Fitzsimmons (sethfitz) merged commit 6bab9be into pydantic Sep 12, 2025
3 checks passed
@sethfitz
Seth Fitzsimmons (sethfitz) deleted the pydantic-cleanup branch September 12, 2025 19:07
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>
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.

2 participants