Repository navigation
fix(client): Make the producer protocols' dest positional-only - #878
Merged
Merged
Conversation
`ProducerProtocol.produce` and `CloseableProducerProtocol.produce` name their first
parameter `dest`. arroyo's `KafkaProducer.produce` names it `destination`. Because
the protocol's parameter could be passed by keyword, a strict checker won't accept
a `KafkaProducer` as a `ProducerProtocol`. ty rejects Seer's producer factory:
```
error[invalid-argument-type]: Argument to `TaskbrokerApp.__init__` is incorrect
--> src/seer/taskworker/app.py:135:5
|
135 | producer_factory=_producer_factory,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Expected `(str, /) -> ProducerProtocol`, found `def _producer_factory(topic: str) -> KafkaProducer`
info: └── the parameter named `destination` does not match `dest` (and can be used as a keyword parameter)
```
mypy doesn't compare parameter names when matching protocols, so it allows this.
`dest` is now positional-only in both protocols. The registry already passes it
positionally. No behaviour changes.
I checked this by pointing Seer's ty at this branch's source: the error goes away.
mypy on the client reports the same errors before and after.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chromy
marked this pull request as ready for review
November 24, 2026 18:07
untitaker
approved these changes
Nov 25, 2026
untitaker
left a comment
Member
There was a problem hiding this comment.
ugh that's unfortunate. since protocols don't get their arg names checked, i wonder if we should make all protocols positional-only on principle. TIL
3 tasks done
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.
ProducerProtocol.produceandCloseableProducerProtocol.producename their firstparameter
dest.arroyo'sKafkaProducer.producenames itdestination. Becausethe protocol's parameter could be passed by keyword, a strict checker won't accept
a
KafkaProduceras aProducerProtocol.tyrejects Seer's producer factory:mypydoesn't compare parameter names when matching protocols, so it allows this.destis now positional-only in both protocols. The registry already passes itpositionally.