Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed May 11, 2023
1 parent ab283b6 commit 9a27311
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion aio_pika/patterns/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ..tools import create_task, ensure_awaitable
from .base import Base, CallbackType, Proxy, T


log = logging.getLogger(__name__)


Expand Down Expand Up @@ -179,7 +180,7 @@ async def create_worker(
""" Creates a new :class:`Worker` instance. """
queue = await self.create_queue(queue_name, **kwargs)
consumer_tag = await queue.consume(
partial(self.on_message, ensure_awaitable(func))
partial(self.on_message, ensure_awaitable(func)),
)

return Worker(queue, consumer_tag, self.loop)
Expand Down
3 changes: 2 additions & 1 deletion aio_pika/patterns/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
from aio_pika.exchange import ExchangeType
from aio_pika.message import IncomingMessage, Message, ReturnedMessage

from .base import Base, CallbackType, Proxy, T
from ..tools import ensure_awaitable
from .base import Base, CallbackType, Proxy, T


log = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion aio_pika/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from functools import partial
from types import TracebackType
from typing import Any, Callable, Optional, Type, overload, Awaitable
from typing import Any, Awaitable, Callable, Optional, Type, overload

import aiormq
from aiormq.abc import DeliveredMessage
Expand All @@ -18,6 +18,7 @@
from .message import IncomingMessage
from .tools import CallbackCollection, create_task, ensure_awaitable


if sys.version_info >= (3, 8):
from typing import Literal
else:
Expand Down
2 changes: 1 addition & 1 deletion aio_pika/robust_queue.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings
from random import Random
from typing import Any, Callable, Dict, Optional, Tuple, Union, Awaitable
from typing import Any, Awaitable, Callable, Dict, Optional, Tuple, Union

import aiormq
from aiormq import ChannelInvalidStateError
Expand Down
2 changes: 1 addition & 1 deletion aio_pika/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def __call__(self, *args: Any, **kwargs: Any) -> Awaitable[Any]:


def ensure_awaitable(
func: Callable[..., Union[T, Awaitable[T]]]
func: Callable[..., Union[T, Awaitable[T]]],
) -> Callable[..., Awaitable[T]]:
if inspect.iscoroutinefunction(func):
return func
Expand Down
7 changes: 3 additions & 4 deletions tests/test_rpc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import logging
import warnings

from functools import partial

import pytest
Expand Down Expand Up @@ -197,7 +196,7 @@ def bypass(_):
await rpc.register(
"test.non-coroutine",
bypass, # type: ignore
auto_delete=True
auto_delete=True,
)

async def coro(_):
Expand All @@ -208,7 +207,7 @@ async def coro(_):
await rpc.register(
"test.coroutine",
coro, # type: ignore
auto_delete=True
auto_delete=True,
)

assert len(record) == 1
Expand All @@ -218,7 +217,7 @@ async def coro(_):
await rpc.register(
"test.coroutine_partial",
partial(partial(coro)), # type: ignore
auto_delete=True
auto_delete=True,
)

assert len(record) == 1
2 changes: 1 addition & 1 deletion tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def __call__(self, *args, **kwargs):
class TestEnsureAwaitable:
async def test_non_coroutine(self):
with pytest.deprecated_call(match="You probably registering the"):
func = ensure_awaitable(lambda x: x*x)
func = ensure_awaitable(lambda x: x * x)

with pytest.deprecated_call(match="Function"):
assert await func(2) == 4
Expand Down

0 comments on commit 9a27311

Please sign in to comment.