Skip to content

Fix async builder fluent typing#1560

Merged
skrawcz merged 1 commit into
apache:mainfrom
Abdeltoto:fix-async-builder-typing
May 3, 2026
Merged

Fix async builder fluent typing#1560
skrawcz merged 1 commit into
apache:mainfrom
Abdeltoto:fix-async-builder-typing

Conversation

@Abdeltoto

Copy link
Copy Markdown
Contributor

Summary

  • Use typing_extensions.Self for fluent driver.Builder methods that return self.
  • Annotate async_driver.Builder.build() as returning AsyncDriver when awaited.
  • This preserves the async builder type through chains like async_driver.Builder().with_modules(...).build() instead of falling back to the synchronous driver.Builder.build() type.

Fixes #1452

Test plan

  • python -m ruff check hamilton/driver.py hamilton/async_driver.py
  • git diff --check
  • python -m pytest tests/test_async_driver.py -k Builder could not run locally because typing_inspect is not installed in this environment.
  • pyright is not installed locally, so I could not run the original reporter's checker here.

@skrawcz skrawcz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! LGTM — clean use of Self for the fluent builder pattern.

@skrawcz skrawcz merged commit 3c48005 into apache:main May 3, 2026
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.

Typing issue when defining an async driver

2 participants