Skip to content

Annotate asset and builder return types#86

Merged
jirhiker merged 1 commit into
mainfrom
chore/asset-return-types
Jun 26, 2026
Merged

Annotate asset and builder return types#86
jirhiker merged 1 commit into
mainfrom
chore/asset-return-types

Conversation

@jirhiker

Copy link
Copy Markdown
Member

What

The Dagster asset compute functions and their builders were unannotated, so mypy and Dagster inferred Any. Add precise return types.

Changes

  • Asset compute fns: _source_asset -> Iterator[dg.Output | dg.AssetCheckResult] (it yields both). Combine/geoserver already returned dg.MaterializeResult.
  • Builders: _build_source_asset -> tuple[AssetsDefinition, AssetKey]; _build_combine_asset / _build_geoserver_asset -> AssetsDefinition; build_product_assets -> list[AssetsDefinition].
  • definitions.py: _build_assets -> list[AssetsDefinition]; _build_jobs -> dict[str, UnresolvedAssetJobDefinition] (imported under TYPE_CHECKING — it isn't a public dagster export); _build_schedules -> list[ScheduleDefinition]; _products -> Iterator[dict].
  • Helpers: _product_params / _product_source_keys -> list[str]; annotated the source asset's records/sites/timeseries accumulators (list[dict] / list[list[dict]]).

Verification

  • mypy clean on products.py and definitions.py (the annotations surfaced and fixed an untyped-accumulator inference issue).
  • Definitions load; 13 persister tests pass.

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

Your pull request is automatically being deployed to Dagster Cloud.

Location Status Link Updated
die-orchestration View in Cloud Jun 26, 2026 at 09:16 PM (UTC)

@jirhiker jirhiker merged commit 38ec419 into main Jun 26, 2026
2 checks passed
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.

1 participant