refactor!: definitions are built once, in Component.definition - #339
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The ten-field `ComponentDefinition(...)` constructor call was copied into five `definition()` overrides (Component, Resource, Source, Asset, Destination), each drifting a little: Source and Asset left out `state_schema`, only Source and Destination validated `FetchField` providers. `DestinationDefinition` was an empty subclass whose sole purpose was to be returned by one of those copies. `Component.definition()` is now the one place a class is described, and it validates fetch-field providers for every kind. A kind that carries more builds its own model from the base one, `SourceDefinition(**dict(super().definition()), assets=...)`: Source nests its assets, Asset adds the output schema and partitioning (its path through `Asset.classpath`), Resource only changes the type. `DestinationDefinition` and `Destination.definition()` are deleted: a destination describes nothing beyond the base. By Digitl
aaaaahaaaaa
force-pushed
the
refactor/destination-definition
branch
from
September 10, 2026 14:56
2b9cf0b to
5f345c6
Compare
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
Destination review item 8, taken to its root.
Destination.definition()duplicatedComponent.definition()to returnDestinationDefinition, an empty subclass. Looking wider, the same ten-fieldComponentDefinition(...)call was copied into five overrides, each drifting a little:SourceandAssetleft outstate_schema, and onlySourceandDestinationvalidatedFetchFieldproviders.Now:
Component.definition()is the one place a class is described. It validates everyFetchFieldprovider against the class's relations, for every kind.SourceDefinition(**dict(super().definition()), assets=...).Sourcenests its assets,Assetaddsasset_schemaandpartitioning(its path throughAsset.classpath),Resourceonly changes the type.ConnectionandOAuthConnectionkeep enrichingsuper().definition()as before.DestinationDefinitionandDestination.definition()are deleted: a destination describes nothing beyond the base, and its definition is a plainComponentDefinition. The app already typed it as an alias ofComponentDefinition.No second entry point:
definition()is the only way a class is described.Verification
uv run --frozen ruff check,uv run --frozen ty check: all checks passed.uv run --frozen pytest -q: 2804 passed. New tests: a fetch-field provider naming an undeclared relation now fails on an asset too; a destination's definition is the plain model and the removed export is gone.Follow-up
By Digitl