Repository navigation
fix: give Route and the publisher object the options the broker takes - #3219
Merged
Merged
Conversation
`Route` and the publisher object are written by hand next to the registrator, so an option added to one is easy to forget in the other. The test compares the parameter names and pins today's gaps in a table that only shrinks. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`Route` and the publisher object copy the registrator arguments by hand, so `codec` (#2841) and `persistent` reached the registrator and not them; rabbit also lost `channel` and redis `message_format` / `autoflush`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Lancetnik
requested review from
borisalekseev and
powersemmi
as code owners
September 22, 2026 05:05
IvanKirpichnikov
requested changes
Sep 23, 2026
One small test per broker, next to its other tests, over a shared helper in `tests/brokers/base/option_surface.py`. The classes are imported by name instead of looked up by string, so a rename breaks the import, not the test. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
IvanKirpichnikov
approved these changes
Sep 23, 2026
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.
The Option surface rule (#2871) says an option exists at every level it can reasonably be set. Nothing checked it: mypy over
faststream/cannot see a missing keyword — that is a call-site error, which is whytests/mypy/*exists and is written by hand.The check
For each broker, compare the parameter names of
broker.subscriber/broker.publisheragainst the router, theRouteobject and the publisher object, and assert the four results at once (tests/brokers/test_option_surface.py).Broker.subscriberandRouter.subscriberare the same registrator function (isholds for all six brokers and both methods), so those two rows cannot fail today. They stay in the assertion as a guard: the moment a router gets a signature of its own that drops an option, the test says so.What it found, and this PR fixes
Routeand the publisher objects are hand-written copies of the registrator arguments, and they were behind:Routecodec,persistentautoflush,persistentcodec,persistentautoflush,persistentcodec,persistentpersistentchannel,codec,persistentpersistentcodec,message_format,persistentmessage_format,persistentcodeccodeccame in with #2841 andpersistentwith the 0.7.0 work; both were added to the registrator and not to the objects beside it. Each parameter keeps the registrator's own type, default and docstring line, and is forwarded to it — nothing else changes.Before this,
KafkaRoute(handler, "topic", persistent=False)raisedTypeError. Now it registers a non-persistent subscriber: withpersistent=Falsethe registrator keeps 0 subscribers and 0 publishers, withpersistent=Trueit keeps 1 and 1 — the same asbroker.subscriber(..., persistent=False).Checks
The test goes red on a real regression: adding a parameter to the Kafka registrator made the
Routerow grow it.mypy(1850 files),pyright(0 errors),ruff,ruff format,slotscheck, both collection gates, and the router / include-router tests of all six brokers plus this file (275 passed).