Skip to content

chore: adopt faststream 0.7.1 TestBroker typing fix#27

Merged
lesnik512 merged 8 commits into
mainfrom
chore/faststream-0.7.1-testbroker-typing
Jun 4, 2026
Merged

chore: adopt faststream 0.7.1 TestBroker typing fix#27
lesnik512 merged 8 commits into
mainfrom
chore/faststream-0.7.1-testbroker-typing

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

  • Bumps faststream floor from >=0.7,<0.8 to >=0.7.1,<0.8.
  • Drops the TestTimersBroker.__aenter__ workaround that existed to coerce upstream's old Broker | list[Broker] return type. fix(testing): type TestBroker context result via __init__ overloads ag2ai/faststream#2903 fixes this in 0.7.1 by making TestBroker generic over a second EnterType TypeVar; we bind it to TimersBroker.
  • Updates the ASGI registry annotation in __init__.py to match upstream's new type[TestBroker[Any, Any]] shape.
  • Adds a regression test in tests/test_fake.py that guards the single-TimersBroker __aenter__ contract.

See planning/specs/2026-06-04-faststream-0.7.1-testbroker-typing-design.md and planning/plans/2026-06-04-faststream-0.7.1-testbroker-typing-plan.md for the full design + plan.

Test plan

  • just lint passes (ruff format, ruff check, ty check, eof-fixer).
  • just test passes — 107/107 across the full suite (test_unit, test_fake, test_delivery, test_cancel, test_isolation, test_envelope, plus the new regression test).
  • New regression test_test_broker_aenter_returns_single_timers_broker passes 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:

  1. `chore: bump faststream pin to >=0.7.1`
  2. `test: add regression for TestTimersBroker aenter return shape`
  3. `refactor: drop TestTimersBroker aenter workaround`
  4. `refactor: align ASGI registry annotation with faststream 0.7.1`
  5. `chore: ruff/format cleanup` (line wrapping after annotation widening)
  6. `docs(spec): align with shipped implementation` (test placement + assertion notes)

🤖 Generated with Claude Code

lesnik512 and others added 8 commits June 4, 2026 09:57
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>
@lesnik512 lesnik512 self-assigned this Jun 4, 2026
@lesnik512 lesnik512 merged commit 88c9f30 into main Jun 4, 2026
3 checks passed
@lesnik512 lesnik512 deleted the chore/faststream-0.7.1-testbroker-typing branch June 4, 2026 09:20
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