Skip to content

[REFACTOR] Organize divisions theme Pydantic package, add missing relationships, tidy and add docs#469

Merged
Victor Schappert (vcschapp) merged 2 commits intodevfrom
reorg-divisions
Mar 12, 2026
Merged

[REFACTOR] Organize divisions theme Pydantic package, add missing relationships, tidy and add docs#469
Victor Schappert (vcschapp) merged 2 commits intodevfrom
reorg-divisions

Conversation

@vcschapp
Copy link
Copy Markdown
Collaborator

@vcschapp Victor Schappert (vcschapp) commented Mar 12, 2026

Description

Continuing the Pydantic package polishing journey from late 2025, this PR cleans up the divisions theme. After this,
only transportation and some final tweaks to core (soon to be common) will remain.

tl;dr

  • Aligned organization of divisions theme with addresses, base, buildings, and places.
  • Added missing relationships.
  • Edited and tidied docs.
  • Added docs coverage.

Merge guidance: Rebase

Two two commits in the history are intentional. This PR should be rebased.

Journey

This PR follows a sequence of PRs I published in late 2025 that started the cleanup process, but did leave it somewhat incomplete. These are the earlier ones.

This PR is basically episode 6.

Documentation website

Update the hyperlink below to put the pull request number in.

Docs preview for this PR.

Signed-off-by: schapper <schapper@amazon.com>
Comment on lines +26 to +33
CAPITAL_OF = "capital_of", "The relator is a capital of the relatee"
CAPITALLED_BY = "capitalled_by", "the relatee is a capital of the relator"
CHILD_OF = "child_of", "The relator is a child of the relatee"
CONNECTS_TO = "connects_to", "The relator connects to the relatee"
DESCENDANT_OF = (
"descendant_of",
"The relator is a hierarchical descentant of the relatee",
)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TristanDiet-TomTom, it happened exactly as you predicted!

I found that four relationships in divisions weren't modeled yet. Since none of them had an appropriate relationship, I had to add four new relationship types: CAPITAL_OF, CAPITALLED_BY, CHILD_OF, and DESCENDANT_OF.

These should be thought of as temporary, since when we put your new system in place all the existing relationship types will fold into the new system.

@mojodna
Copy link
Copy Markdown
Collaborator

The docs preview link is wrong and the staging link (https://staging.overturemaps.org/docs/pr/469/...) isn't working either. I wanted to see how this affected the nav.

@vcschapp
Copy link
Copy Markdown
Collaborator Author

The docs preview link is wrong and the staging link (https://staging.overturemaps.org/docs/pr/469/...) isn't working either. I wanted to see how this affected the nav.

Interesting. I'm guessing that structural change has broken the previously working staging links, which haven't been used much lately?

This commit organizes the divisions Pydantic package to align with the
other packages that have been done so far: addresses, base, buildings,
and places. After this commit there remains only: transportation and
core (the latter will soon be renamed common).

Organization work done:

1. Common code into `_common.py`.
2. Each feature type gets its own main module, e.g., `division.py`.
3. Types used exclusively by a feature type into that feature type's main
   module, regardless of whether the type is an enum, model, NewType, etc.
4. Eliminate sub-directories.
5. Curate `__all__` in `__init__.py`.

Missing relationships added:

1. `CapitalOfItem`
2. `HierarchyItem`
3. `parent_division_id` in `Division`
4. `capital_division_ids` in `Division`

Getting this to work required extending the list of relationships in the
system package's `ref.py`. (On this, note, that Tristan will likely
shrink it back to managable size when he rationalizes the
relationships.) It also required solving an issue with Python forward
references being in the Pydantic field annotations for `CapitalOfItem`
and `HierarchyItem`, which was breaking codegen. I fixed this issue by
using `.model_rebuild()` on both models, see `divisions.py`.

Docs tidied and updated:

1. Eliminated all `make docformat` errors pertaining to divisions.
2. Converted several enums to `DocumentedEnum` so they can have a richer
   presence in the schema reference.
3. Added missing docstrings and `Field(description="...")` annotations.
4. Edited and refined some of the documentation wording where it wasn't
   fully up to standard.
5. Wrapped long doc/desc lines using `textwrap.dedent("...").strip()` so
   the docs are easier to read and edit in a code editor.

Signed-off-by: schapper <schapper@amazon.com>
@vcschapp Victor Schappert (vcschapp) merged commit ac45fe7 into dev Mar 12, 2026
5 of 6 checks passed
@vcschapp Victor Schappert (vcschapp) deleted the reorg-divisions branch March 12, 2026 16:06
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