Annotate asset and builder return types#86
Merged
Conversation
The asset compute fns and builders were unannotated, so mypy/Dagster inferred Any. Add precise types: - _source_asset -> Iterator[dg.Output | dg.AssetCheckResult] (yields both). - _build_source_asset -> tuple[AssetsDefinition, AssetKey]; _build_combine_asset / _build_geoserver_asset -> AssetsDefinition; build_product_assets -> list[AssetsDefinition]. - definitions: _build_assets -> list[AssetsDefinition], _build_jobs -> dict[str, UnresolvedAssetJobDefinition] (TYPE_CHECKING import, not a public export), _build_schedules -> list[ScheduleDefinition], _products -> Iterator[dict]. - helpers: _product_params/_product_source_keys -> list[str]; annotate the source asset's record/site/timeseries accumulators. mypy clean on both files; defs load; 13 persister tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Your pull request is automatically being deployed to Dagster Cloud.
|
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.
What
The Dagster asset compute functions and their builders were unannotated, so mypy and Dagster inferred
Any. Add precise return types.Changes
_source_asset -> Iterator[dg.Output | dg.AssetCheckResult](it yields both). Combine/geoserver already returneddg.MaterializeResult._build_source_asset -> tuple[AssetsDefinition, AssetKey];_build_combine_asset/_build_geoserver_asset -> AssetsDefinition;build_product_assets -> list[AssetsDefinition]._build_assets -> list[AssetsDefinition];_build_jobs -> dict[str, UnresolvedAssetJobDefinition](imported underTYPE_CHECKING— it isn't a public dagster export);_build_schedules -> list[ScheduleDefinition];_products -> Iterator[dict]._product_params/_product_source_keys -> list[str]; annotated the source asset'srecords/sites/timeseriesaccumulators (list[dict]/list[list[dict]]).Verification
mypyclean onproducts.pyanddefinitions.py(the annotations surfaced and fixed an untyped-accumulator inference issue).🤖 Generated with Claude Code