Skip to content

refactor!: introduce annotated Source type alias in models - #289

Open
ArdaTkn wants to merge 1 commit into
SkyeAv:mainfrom
ArdaTkn:refactor/annotated-source-type
Open

ArdaTkn wants to merge 1 commit into
SkyeAv:mainfrom
ArdaTkn:refactor/annotated-source-type

Conversation

@ArdaTkn

@ArdaTkn ArdaTkn commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Closes #286.

Summary

  • Define Source: TypeAlias = Annotated[Excel | Text | Parquet | IPC | NDJSON, Field(discriminator="kind")] in src/tablassert/models.py.
  • Replace repeated Excel | Text | Parquet | IPC | NDJSON unions in _section_source_label and Section.source with Source.
  • Add an Unreleased changelog entry in CHANGELOG.md.

Local gate

  • scripts/check_changelog.py --base upstream/main: PASS
  • ruff check . / ruff format --check .: clean
  • pyright: 0 errors
  • vulture / deptry .: clean
  • pytest -q: 1397 passed (3 pre-existing macOS-only errno/semaphore failures)

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc0f603f-7989-43ff-b022-aaa3ad604d99
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ArdaTkn
ArdaTkn force-pushed the refactor/annotated-source-type branch from e3bf24a to 693f70a Compare November 19, 2026 22:49

@SkyeAv SkyeAv left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the contribution, @ArdaTkn! The alias looks clean and matches #286, but the discriminator makes this a breaking change rather than a pure refactor: kind is now effectively required. Every kind field has a default (src/tablassert/models.py:276-300), so the old plain union accepted configs omitting it; {"source": {"path": "p.csv"}} validated as Excel. With the discriminator the same payload now fails with union_tag_not_found. Before merging, please:

  • Update docs/configuration/table.md:94, :121, and the kind callout at :114-115, which still document kind as optional and claim an omitted kind is accepted.
  • Note the breaking nature in the Unreleased changelog entry: configs omitting kind now fail validation. The PR title should be breaking-marked too (refactor!:).

Verified locally on pydantic v2; targeted checks otherwise pass.

@ArdaTkn
ArdaTkn force-pushed the refactor/annotated-source-type branch from 693f70a to 4b4bea3 Compare November 19, 2026 23:08
@ArdaTkn ArdaTkn changed the title refactor: introduce annotated Source type alias in models refactor!: introduce annotated Source type alias in models Nov 19, 2026
@ArdaTkn

ArdaTkn commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all review items in 4b4bea3:

  1. docs/configuration/table.md: Marked kind as Required: Yes across all five source tables (excel, text, parquet, ipc, ndjson) and consolidated the duplicate callout at lines 114-115 into a single callout noting that omitting kind now fails validation (union_tag_not_found).
  2. CHANGELOG.md: Marked the Unreleased entry as **BREAKING: and documented that configs omitting source.kind now fail validation with union_tag_not_found.
  3. PR title & commit: Updated both to refactor!: introduce annotated Source type alias in models.
  4. Test coverage: Added test_section_source_requires_kind in tests/test_cover_models.py verifying ValidationError with union_tag_not_found.

Local gates re-run and passing: check_changelog.py, ruff check, ruff format --check, pyright, vulture, deptry, mkdocs build --strict, and pytest (188 passed).

@ArdaTkn
ArdaTkn force-pushed the refactor/annotated-source-type branch from 4b4bea3 to 1edc525 Compare November 19, 2026 23:38

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

introduce a single annotated Source type for the Excel | Text | Parquet | IPC | NDJSON union

2 participants