Repository navigation
fix(mqtt): subscriber() is typed by max_workers, so a decorated handler stays typed - #3123
Merged
Merged
Conversation
…andler stays typed `MQTTRegistrator.subscriber` returned `MQTTDefaultSubscriber | MQTTConcurrentSubscriber`, and strict mypy counts a union-typed decorator as untyped: every `@broker.subscriber(...)` on an MQTT broker or router reported `untyped-decorator`. The two `max_workers` overloads the MQTT FastAPI router already has now sit on the registrator too, so the subscriber and the decorated handler get their exact types. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Lancetnik
requested review from
IvanKirpichnikov and
borisalekseev
as code owners
September 12, 2026 14:23
borisalekseev
approved these changes
Sep 12, 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.
Description
MQTTRegistrator.subscriberreturnsMQTTDefaultSubscriber | MQTTConcurrentSubscriber. Strict mypy treats a union-typed decorator as untyped, so any handler under@broker.subscriber(...)on anMQTTBrokerorMQTTRouterreportsuntyped-decorator, and the handler loses its type:The registrator gains the two
max_workersoverloads the MQTT FastAPI router already has:max_workers: Literal[1]returnsMQTTDefaultSubscriber, any otherintreturnsMQTTConcurrentSubscriber.tests/mypy/mqtt.pypins both subscriber types and the decorated handler's type; both checks go red on the old registrator.Split out of #3120, where the MQTT Call assertions needed it; it is a fix on its own.
Type of change
Checklist
just lintshows no errors)just static-analysis🤖 Generated with Claude Code