chore: migrate to faststream 0.7 (breaking: drop per-call middlewares=)#26
Merged
Conversation
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.
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
faststream>=0.6,<0.7→>=0.7,<0.8. Drops 0.6 support entirely (no compat shim).codec: CodecProtoattribute onTimersProducer,awaitonTimerMessageFormat.encode(...)(discovered: encode became async in 0.7),create_publisher_fake_subscriberinstance form,add_callkwarg trim, and a narrowed__aenter__override onTestTimersBrokerto silence 0.7's multi-broker union.middlewares=kwarg is removed fromTimersRegistrator.subscriber,TimersRegistrator.publisher,TimersRoute, andTimersRoutePublisher. Use broker-scopeTimersBroker(middlewares=[...])instead.No new 0.7 features are adopted in this PR (broker-level
AckPolicydefault, 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.7defensively.Test plan
just lintclean (ruff + ty + eof-fixer).just testgreen: 106 tests, 100% coverage (Redis-backed integration suite included).uv run pytest tests/test_unit.py tests/test_fake.pygreen standalone.git grep -n "middlewares_=\|middlewares=" faststream_redis_timers/ tests/returns onlybroker_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.