From bec84f71f95ea2f826c681e4ef080bcf0ee663d1 Mon Sep 17 00:00:00 2001 From: Nikita Pastukhov Date: Fri, 18 Oct 2024 23:32:13 +0300 Subject: [PATCH] lint: polish annotations --- faststream/_internal/publisher/proto.py | 7 ++-- faststream/nats/publisher/producer.py | 46 ++++++++++++------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/faststream/_internal/publisher/proto.py b/faststream/_internal/publisher/proto.py index 71af06f5e1..e2465aaac4 100644 --- a/faststream/_internal/publisher/proto.py +++ b/faststream/_internal/publisher/proto.py @@ -26,15 +26,12 @@ class ProducerProto(Protocol): _decoder: "AsyncCallable" @abstractmethod - async def publish(self, message: "PublishCommand") -> Optional[Any]: + async def publish(self, cmd: "PublishCommand") -> Optional[Any]: """Publishes a message asynchronously.""" ... @abstractmethod - async def request( - self, - message: "PublishCommand", - ) -> Any: + async def request(self, cmd: "PublishCommand") -> Any: """Publishes a message synchronously.""" ... diff --git a/faststream/nats/publisher/producer.py b/faststream/nats/publisher/producer.py index a4bd1c33f3..57e194e793 100644 --- a/faststream/nats/publisher/producer.py +++ b/faststream/nats/publisher/producer.py @@ -44,39 +44,39 @@ def __init__( @override async def publish( # type: ignore[override] self, - message: "NatsPublishCommand", + cmd: "NatsPublishCommand", ) -> None: - payload, content_type = encode_message(message.body) + payload, content_type = encode_message(cmd.body) headers_to_send = { "content-type": content_type or "", - **message.headers_to_publish(), + **cmd.headers_to_publish(), } await self._connection.publish( - subject=message.destination, + subject=cmd.destination, payload=payload, - reply=message.reply_to, + reply=cmd.reply_to, headers=headers_to_send, ) @override async def request( # type: ignore[override] self, - message: "NatsPublishCommand", + cmd: "NatsPublishCommand", ) -> "Msg": - payload, content_type = encode_message(message.body) + payload, content_type = encode_message(cmd.body) headers_to_send = { "content-type": content_type or "", - **message.headers_to_publish(), + **cmd.headers_to_publish(), } return await self._connection.request( - subject=message.destination, + subject=cmd.destination, payload=payload, headers=headers_to_send, - timeout=message.timeout, + timeout=cmd.timeout, ) @@ -102,21 +102,21 @@ def __init__( @override async def publish( # type: ignore[override] self, - message: "NatsPublishCommand", + cmd: "NatsPublishCommand", ) -> Optional[Any]: - payload, content_type = encode_message(message.body) + payload, content_type = encode_message(cmd.body) headers_to_send = { "content-type": content_type or "", - **message.headers_to_publish(js=True), + **cmd.headers_to_publish(js=True), } await self._connection.publish( - subject=message.destination, + subject=cmd.destination, payload=payload, headers=headers_to_send, - stream=message.stream, - timeout=message.timeout, + stream=cmd.stream, + timeout=cmd.timeout, ) return None @@ -124,9 +124,9 @@ async def publish( # type: ignore[override] @override async def request( # type: ignore[override] self, - message: "NatsPublishCommand", + cmd: "NatsPublishCommand", ) -> "Msg": - payload, content_type = encode_message(message.body) + payload, content_type = encode_message(cmd.body) reply_to = self._connection._nc.new_inbox() future: asyncio.Future[Msg] = asyncio.Future() @@ -136,16 +136,16 @@ async def request( # type: ignore[override] headers_to_send = { "content-type": content_type or "", "reply_to": reply_to, - **message.headers_to_publish(js=False), + **cmd.headers_to_publish(js=False), } - with anyio.fail_after(message.timeout): + with anyio.fail_after(cmd.timeout): await self._connection.publish( - subject=message.destination, + subject=cmd.destination, payload=payload, headers=headers_to_send, - stream=message.stream, - timeout=message.timeout, + stream=cmd.stream, + timeout=cmd.timeout, ) msg = await future