Skip to content

chore: migrate to faststream 0.7 (breaking: drop per-call middlewares=)#26

Merged
lesnik512 merged 2 commits into
mainfrom
chore/faststream-0.7-migration
Jun 3, 2026
Merged

chore: migrate to faststream 0.7 (breaking: drop per-call middlewares=)#26
lesnik512 merged 2 commits into
mainfrom
chore/faststream-0.7-migration

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

  • Bumps faststream>=0.6,<0.7>=0.7,<0.8. Drops 0.6 support entirely (no compat shim).
  • Fixes the mechanical 0.7 break points: codec: CodecProto attribute on TimersProducer, await on TimerMessageFormat.encode(...) (discovered: encode became async in 0.7), create_publisher_fake_subscriber instance form, add_call kwarg trim, and a narrowed __aenter__ override on TestTimersBroker to silence 0.7's multi-broker union.
  • Breaking change for downstream consumers: the per-call middlewares= kwarg is removed from TimersRegistrator.subscriber, TimersRegistrator.publisher, TimersRoute, and TimersRoutePublisher. Use broker-scope TimersBroker(middlewares=[...]) instead.

No new 0.7 features are adopted in this PR (broker-level AckPolicy default, multi-broker, Redis Cluster, MQTT each get their own follow-up if we want them).

Companion to PR #25 which tightened the pin to <0.7 defensively.

Test plan

  • just lint clean (ruff + ty + eof-fixer).
  • just test green: 106 tests, 100% coverage (Redis-backed integration suite included).
  • uv run pytest tests/test_unit.py tests/test_fake.py green standalone.
  • git grep -n "middlewares_=\|middlewares=" faststream_redis_timers/ tests/ returns only broker_middlewares= and _extra_middlewares= (broker-scope + internal-only).
  • git grep -n "faststream~=0.6\|faststream<0.7\|faststream>=0.6,<0.7" . returns nothing in code.
  • python -c "from faststream_redis_timers import TimersBroker, TimersRouter, TestTimersBroker, TimerSub" exits 0.

lesnik512 added 2 commits June 3, 2026 22:38
Bump dependency from `faststream>=0.6,<0.7` to `>=0.7,<0.8`. Drops support
for the 0.6 series entirely (single code path, no compat shim).

Mechanical 0.7 fix points:
- publisher/producer.py: TimersProducer gains `codec: CodecProto =
  DefaultCodec()` class-level default to satisfy 0.7's ProducerProto.
  FakeTimersProducer inherits the attribute.
- publisher/producer.py + testing.py: `await TimerMessageFormat.encode(...)`
  at both publish sites. BinaryMessageFormatV1.encode became async in 0.7;
  discovered during ty diagnostic, not anticipated in the spec.
- testing.py: create_publisher_fake_subscriber drops @staticmethod and
  gains `self` — 0.7's TestBroker base declares it as an instance method.
- testing.py: new `__aenter__` override narrows the return type to
  TimersBroker (upstream returns `Broker | list[Broker]` for the new
  multi-broker support; our subclass enforces single-broker via __init__).
- registrator.py: TimersRegistrator.subscriber drops `middlewares=` kwarg;
  add_call(...) drops `middlewares_=` (0.7 removed it from the base).

Public API break — `middlewares=` per-call kwarg removed from:
- TimersRegistrator.subscriber / .publisher
- TimersRoute / TimersRoutePublisher
- internal plumbing in publisher/factory.py
Upstream removed per-subscriber/per-publisher middleware in 0.7. We
follow suit rather than (a) silently routing to broker scope (semantic
break, surprising), or (b) reimplementing locally (maintenance cost for
a v0 package). Broker-scope middleware via `TimersBroker(middlewares=[...])`
remains the supported entry point.

Test changes:
- tests/test_envelope.py: `test_envelope_size_smaller_than_legacy`
  converted to `async def` + `await` for the now-async encode.
- tests/test_unit.py: two new TDD pin tests for codec attribute and
  create_publisher_fake_subscriber instance form.

No 0.7 features adopted (broker-level AckPolicy default, multi-broker,
Redis Cluster, MQTT). Each gets its own follow-up if/when we want it.
@lesnik512 lesnik512 self-assigned this Jun 3, 2026
@lesnik512 lesnik512 merged commit 1903a8b into main Jun 3, 2026
3 checks passed
@lesnik512 lesnik512 deleted the chore/faststream-0.7-migration branch June 3, 2026 19:41
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