From 966b406151b81e2022f914309cd91f80ff93237c Mon Sep 17 00:00:00 2001 From: Hector Date: Tue, 24 Nov 2026 17:23:59 +0000 Subject: [PATCH] fix(client): Make the producer protocols' dest positional-only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 --- clients/python/src/taskbroker_client/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/python/src/taskbroker_client/types.py b/clients/python/src/taskbroker_client/types.py index 1388bc1a..0658fd78 100644 --- a/clients/python/src/taskbroker_client/types.py +++ b/clients/python/src/taskbroker_client/types.py @@ -39,7 +39,7 @@ class ProducerProtocol(Protocol): """Interface for producers that tasks depend on.""" def produce( - self, dest: Topic | Partition, payload: KafkaPayload + self, dest: Topic | Partition, /, payload: KafkaPayload ) -> ProducerFuture[BrokerValue[KafkaPayload]]: ... @@ -47,7 +47,7 @@ class CloseableProducerProtocol(Protocol): """Interface used by TaskProducer. Represents a producer that has a shutdown method.""" def produce( - self, dest: Topic | Partition, payload: KafkaPayload + self, dest: Topic | Partition, /, payload: KafkaPayload ) -> ProducerFuture[BrokerValue[KafkaPayload]]: ... def close(self) -> Future[None]: ...