chore: three small clean-ups in one PR - #3100
Merged
Merged
Conversation
The context prefix a `Path()` parameter reads from has one definition, `PATH_CONTEXT_PREFIX`, instead of a string spelled inline. The MQTT Subscriber and the in-memory MQTT test broker choose the parser class for a Broker version through one function, `parser_for`, instead of each deciding on its own. Nothing a user can see changes. Prefactor extracted from #3030. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Lancetnik
requested review from
IvanKirpichnikov and
borisalekseev
as code owners
September 7, 2026 20:23
borisalekseev
requested changes
Sep 7, 2026
borisalekseev
left a comment
Collaborator
There was a problem hiding this comment.
Better to narrow the mqtt version string type to Literal["3.1.1", "5.0"] and use typing.assert_never. This will simplify the work when adding a protocol version, and mypy will highlight places where corrections need to be made.
…re exhaustive `MQTTVersion = Literal["3.1.1", "5.0"]` is spelled once, in the parser module, and the Broker, the FastAPI router, the Broker config and the test broker read their version through it. `parser_for` and the producer choice in the Broker constructor switch over it exhaustively with `assert_never`, so adding a protocol version is an edit to the alias and mypy names every switch that has to learn it. The Subscriber reads its version as the config spells it, `MQTTVersion` or "unset", and resolves "unset" to 5.0 where it is known why: a Subscriber declared on a Router reads before a Broker composes its version in. Requested in review by @borisalekseev. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Member
Author
|
Done in the second commit.
|
IvanKirpichnikov
approved these changes
Sep 7, 2026
borisalekseev
approved these changes
Sep 7, 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
Two clean-ups too small to review on their own, extracted from #3030 so the feature branch stops carrying them:
PATH_CONTEXT_PREFIX— the context prefix aPath()parameter reads from ("message.path.") has exactly one definition, infaststream/_internal/constants.py, andPath()reads it from there. It was spelled inline before.parser_for(version)infaststream/mqtt/parser.py— the MQTT Subscriber and the in-memory MQTT test broker choose the parser class for a Broker version through this one function. Each picked it on its own before, and the two have to agree on which version they speak.The third item the ticket lists, the
.gitignoreentries for local agent tooling and the graphify output, is already onmain, so it is not part of this PR.Nothing a user can see changes. No new tests: the change is one definition replacing two identical ones, and the existing MQTT and
Path()suites pin the behaviour.Part of the prefactor plan for #2451.
Type of change
Checklist
just lintshows no errors)tests/utils/context/test_path.py,tests/brokers/mqtt/test_path.py,tests/brokers/mqtt/test_testclient.py,tests/docs/mqtt/message/test_message.py(-m "not connected"; MQTTconnectedtests run in CI only)just mypypasses🤖 Generated with Claude Code