Add per-domain input union with Grid variant and match dispatch#25
Merged
Conversation
Replace the single CoverageInput dataclass with _CoverageInputBase + GridInput, keeping CoverageInput as a one-member alias. The modeler dispatches via match/assert_never (version-guarded; typing-extensions added as a 3.10-only conditional dependency), and imagedata_to_coverage_input returns GridInput, dropping its unused geometry/timestamps parameters. Non-3-D arrays now fail at construction instead of in the modeler -- behavior-preserving for the Grid path. Also fold the decisions into docs/04-modeler-converter-design.md (Sections 4/4.1/7 + new 7.5, status callouts on 3/5.1) and refresh the now-resolved Polygon / covjson-pydantic 0.8.0 note. Part of #18. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
emmanuelmathot
approved these changes
Jun 26, 2026
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.
Summary
First of three stacked PRs splitting #18's Story-3 modeler work (part 2a).
Introduces the per-domain input union with only the Grid variant — a
behavior-preserving refactor plus the dispatch foundation that #23
(Point/PointSeries) and #24 (CoverageCollection) build on.
What changed
input.py: replace the singleCoverageInputdataclass with_CoverageInputBase+GridInput; keepCoverageInputas a one-membertype alias. Validation splits into a shared base
__post_init__plus aper-variant
_validate_shapehook (GridInputrequires 3-D(bands, height, width)).imagedata_to_coverage_input()now returnsGridInputand drops itsgeometry/timestampsparameters — on the Grid path they only everreached
NotImplementedError.modeler.to_coverage:match/assert_neverdispatch replacing theGrid-only guards.
assert_neveris version-guarded (stdlib on 3.11+,typing_extensionson 3.10), so adding a variant in Modeler part 2b: Point and PointSeries domains #23 without acasebecomes a mypy error.
typing-extensionsis declared as apython_version < "3.11"conditional dependency.GridInput; the obsolete 2-D / geometry / timestampsand modeler-guard tests are removed (they return as Point-variant tests in
Modeler part 2b: Point and PointSeries domains #23).
docs/04-modeler-converter-design.md(Sections 4/4.1/7 + new 7.5, status callouts on the superseded 3/5.1), and
refresh the resolved Polygon / covjson-pydantic 0.8.0 note.
Behavior
Behavior-preserving for the Grid path — emitted CoverageJSON is unchanged.
The one new behavior: a non-3-D array is rejected at
GridInputconstruction(
ValueError) instead of reaching the modeler.Testing
uv run pytest(251 passed, 100% coverage),ruff check,ruff format --check, andmypyall green on Python 3.10 and 3.13.Part of #18. Closes #22.
🤖 Generated with Claude Code