diff --git a/faststream_concurrent_aiokafka/middleware.py b/faststream_concurrent_aiokafka/middleware.py index 6b61e7f..875fdc1 100644 --- a/faststream_concurrent_aiokafka/middleware.py +++ b/faststream_concurrent_aiokafka/middleware.py @@ -196,7 +196,7 @@ class KafkaConcurrentProcessingMiddleware(BaseMiddleware): # KafkaAckableMessage narrowing documents the MANUAL-ack design center; auto-ack/Fake paths # short-circuit before any narrowed access. Override widens to StreamMessage[Any] semantically # but ty flags the parameter narrowing as a Liskov violation. - async def consume_scope( # ty: ignore[invalid-method-override] + async def consume_scope( # ty: ignore[incompatible-method-override] self, call_next: typing.Callable[[KafkaAckableMessage], typing.Awaitable[typing.Any]], msg: KafkaAckableMessage, diff --git a/faststream_concurrent_aiokafka/rebalance.py b/faststream_concurrent_aiokafka/rebalance.py index 0d6dd1d..6d8b5f6 100644 --- a/faststream_concurrent_aiokafka/rebalance.py +++ b/faststream_concurrent_aiokafka/rebalance.py @@ -67,7 +67,7 @@ def from_context( def _resolve_committer(self) -> KafkaBatchCommitter | None: return self._committer - async def on_partitions_assigned(self, _assigned: object) -> None: # ty: ignore[invalid-method-override] + async def on_partitions_assigned(self, assigned: object) -> None: pass async def on_partitions_revoked(self, revoked: object) -> None: @@ -97,7 +97,7 @@ def _resolve_committer(self) -> KafkaBatchCommitter | None: return None return handler.committer - async def on_partitions_assigned(self, assigned: object) -> None: # ty: ignore[invalid-method-override] + async def on_partitions_assigned(self, assigned: object) -> None: if self._chained is not None: await _call_or_await(self._chained.on_partitions_assigned(assigned)) diff --git a/tests/test_concurrent_processing.py b/tests/test_concurrent_processing.py index 78b0087..e226a4d 100644 --- a/tests/test_concurrent_processing.py +++ b/tests/test_concurrent_processing.py @@ -252,7 +252,7 @@ async def coro() -> str: await handler.handle_task(coro(), sample_record, sample_message) # ty: ignore[invalid-argument-type] assert len(handler._tracked_tasks) == 1 - sent_commit_task: typing.Final = handler._committer.send_task.call_args[0][0] # ty: ignore[unresolved-attribute] + sent_commit_task: typing.Final = handler._committer.send_task.call_args[0][0] # ty: ignore[missing-attribute] assert isinstance(sent_commit_task.asyncio_task, asyncio.Task) assert len(sent_commit_task.asyncio_task._callbacks) > 0 @@ -275,7 +275,7 @@ async def coro() -> str: await handler.handle_task(coro(), sample_record, sample_message) # ty: ignore[invalid-argument-type] - sent_commit_task: typing.Final = handler._committer.send_task.call_args[0][0] # ty: ignore[unresolved-attribute] + sent_commit_task: typing.Final = handler._committer.send_task.call_args[0][0] # ty: ignore[missing-attribute] assert commit_structure_validate({sent_commit_task.topic_partition: 0}) @@ -299,14 +299,14 @@ async def coro() -> str: return "result" await handler.handle_task(coro(), sample_record, sample_message) # ty: ignore[invalid-argument-type] - handler._committer.send_task.assert_called_once() # ty: ignore[unresolved-attribute] + handler._committer.send_task.assert_called_once() # ty: ignore[missing-attribute] async def test_concurrent_handles_committer_dead_error( handler: KafkaConcurrentHandler, sample_message: MockKafkaMessage, sample_record: MockConsumerRecord ) -> None: await handler.start() - handler._committer.send_task.side_effect = CommitterIsDeadError("Dead") # ty: ignore[unresolved-attribute] + handler._committer.send_task.side_effect = CommitterIsDeadError("Dead") # ty: ignore[missing-attribute] with pytest.raises(CommitterIsDeadError): await handler.handle_task(asyncio.sleep(0), sample_record, sample_message) # ty: ignore[invalid-argument-type] @@ -322,7 +322,7 @@ async def test_concurrent_start_sets_running(handler: KafkaConcurrentHandler) -> async def test_concurrent_start_creates_committer_when_enabled(handler: KafkaConcurrentHandler) -> None: await handler.start() - handler._committer.spawn.assert_called_once() # ty: ignore[unresolved-attribute] + handler._committer.spawn.assert_called_once() # ty: ignore[missing-attribute] assert handler.is_healthy @@ -346,7 +346,7 @@ async def test_concurrent_stop_base(handler: KafkaConcurrentHandler) -> None: async def test_concurrent_stop_closes_committer(handler: KafkaConcurrentHandler) -> None: await handler.start() await handler.stop() - handler._committer.close.assert_called_once() # ty: ignore[unresolved-attribute] + handler._committer.close.assert_called_once() # ty: ignore[missing-attribute] async def test_concurrent_stop_when_not_running( diff --git a/tests/test_kafka_committer.py b/tests/test_kafka_committer.py index ab136fc..0a57da8 100644 --- a/tests/test_kafka_committer.py +++ b/tests/test_kafka_committer.py @@ -1355,9 +1355,11 @@ async def done() -> None: timeout=1.0, ) # never blocks - committer._commit_task.cancel() # ty: ignore[unresolved-attribute] + commit_task: typing.Final = committer._commit_task + assert commit_task is not None + commit_task.cancel() with contextlib.suppress(asyncio.CancelledError): - await committer._commit_task # ty: ignore[invalid-await] + await commit_task async def test_send_task_unblocks_with_dead_committer_error() -> None: @@ -1399,9 +1401,11 @@ async def done() -> None: await asyncio.sleep(0.05) assert not blocked.done() - committer._commit_task.cancel() # ty: ignore[unresolved-attribute] + commit_task: typing.Final = committer._commit_task + assert commit_task is not None + commit_task.cancel() with contextlib.suppress(asyncio.CancelledError): - await committer._commit_task # ty: ignore[invalid-await] + await commit_task with pytest.raises(CommitterIsDeadError): await asyncio.wait_for(blocked, timeout=1.0) diff --git a/tests/test_middleware.py b/tests/test_middleware.py index e398e7e..8fde895 100644 --- a/tests/test_middleware.py +++ b/tests/test_middleware.py @@ -764,10 +764,10 @@ async def handler(msg: typing.Any) -> None: ... # No await: a coroutine-returning guard would merely warn here instead of raising. with pytest.raises(RuntimeError, match="ack"): - guarded.ack() # ty: ignore[unresolved-attribute] + guarded.ack() # ty: ignore[missing-attribute] # And it raises through an await too, since the call raises before the await happens. with pytest.raises(RuntimeError, match="ack"): - await guarded.ack() # ty: ignore[unresolved-attribute] + await guarded.ack() # ty: ignore[missing-attribute] async def test_middleware_does_not_guard_fake_consumer_passthrough(setup_broker: KafkaBroker) -> None: diff --git a/tests/test_rebalance.py b/tests/test_rebalance.py index 08dba99..8e26659 100644 --- a/tests/test_rebalance.py +++ b/tests/test_rebalance.py @@ -33,7 +33,7 @@ async def test_rebalance_on_partitions_revoked_calls_commit_all( async def test_rebalance_on_partitions_assigned_is_noop( listener: ConsumerRebalanceListener, committer: MockKafkaBatchCommitter ) -> None: - await listener.on_partitions_assigned(set()) + await listener.on_partitions_assigned(assigned=set()) committer.commit_all.assert_not_called() diff --git a/tests/test_rebalance_attachment.py b/tests/test_rebalance_attachment.py index 8b9d4b5..9e7960a 100644 --- a/tests/test_rebalance_attachment.py +++ b/tests/test_rebalance_attachment.py @@ -121,7 +121,7 @@ async def test_a_user_listener_is_kept_and_still_called(*, is_async: bool) -> No try: handler.committer.commit_all = AsyncMock() await subscriber._listener.on_partitions_revoked(partitions) - await subscriber._listener.on_partitions_assigned(partitions) + await subscriber._listener.on_partitions_assigned(assigned=partitions) finally: await stop_concurrent_processing(broker.context)