chore: adopt faststream 0.7.1 TestBroker typing fix#27
Merged
Conversation
Drop our TestTimersBroker.__aenter__ workaround now that PR ag2ai/faststream#2903 fixes upstream's Broker | list[Broker] return type via a second EnterType TypeVar. Bumps pin to >=0.7.1, rebinds TestBroker[TimersBroker, TimersBroker], updates ASGI registry annotation, and adds a regression test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five tasks: bump pin, add regression test, refactor TestTimersBroker to bind EnterType, update ASGI registry annotation, then final validate + bundled commit. Follows the spec at planning/specs/2026-06-04-faststream-0.7.1-testbroker-typing-design.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Required floor for the TestBroker EnterType typing fix in 0.7.1 (ag2ai/faststream#2903). Workaround removal in subsequent commits. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Guards that the entered context yields a single TimersBroker (not a list or tuple) through the upcoming workaround removal in the next commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
faststream 0.7.1 (ag2ai/faststream#2903) makes TestBroker generic over a second EnterType TypeVar that __aenter__ returns. Bind EnterType to TimersBroker so the base method directly yields a TimersBroker, and delete our override + the now-stale isinstance(list) assert. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Upstream try_it_out._get_broker_registry now types its values as type[TestBroker[Any, Any]] (PR ag2ai/faststream#2903 added a second EnterType TypeVar). Mirror that in our monkey-patched override so the function signatures line up. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Line wrapping and docstring formatting improvements from linter. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Spec said the regression test would live in tests/test_unit.py with two assertions; during execution we placed it in tests/test_fake.py (matches the context-manager test pattern there) and dropped the redundant second assertion (already implied by isinstance(tb, TimersBroker)). Update the spec to reflect what was actually shipped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
faststreamfloor from>=0.7,<0.8to>=0.7.1,<0.8.TestTimersBroker.__aenter__workaround that existed to coerce upstream's oldBroker | list[Broker]return type. fix(testing): type TestBroker context result via __init__ overloads ag2ai/faststream#2903 fixes this in 0.7.1 by makingTestBrokergeneric over a secondEnterTypeTypeVar; we bind it toTimersBroker.__init__.pyto match upstream's newtype[TestBroker[Any, Any]]shape.tests/test_fake.pythat guards the single-TimersBroker__aenter__contract.See
planning/specs/2026-06-04-faststream-0.7.1-testbroker-typing-design.mdandplanning/plans/2026-06-04-faststream-0.7.1-testbroker-typing-plan.mdfor the full design + plan.Test plan
just lintpasses (ruff format, ruff check, ty check, eof-fixer).just testpasses — 107/107 across the full suite (test_unit, test_fake, test_delivery, test_cancel, test_isolation, test_envelope, plus the new regression test).test_test_broker_aenter_returns_single_timers_brokerpasses both before and after the override removal (Tasks 2 + 3 verified this in sequence).Commits
6 commits on the branch — they can be squashed at merge time per the spec's bundled-commit intent:
🤖 Generated with Claude Code