Skip to content

Commit 5f772a4

Browse files
committed
fix: warning about asyncio.iscoroutinefunction usage
1 parent b53a154 commit 5f772a4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ line-length = 88
190190
"S311", # Standard pseudo-random generators are not suitable for security/cryptographic purposes
191191
"D101", # Missing docstring in public class
192192
"D102", # Missing docstring in public method
193-
"PLR2004", # Magic value
194193
]
195194
"docs/examples/*" = [
196195
"D103", # Missing docstring in public function

taskiq/receiver/receiver.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import contextvars
33
import functools
44
import inspect
5+
import sys
56
from collections.abc import Callable
67
from concurrent.futures import Executor
78
from logging import getLogger
@@ -23,6 +24,7 @@
2324
from taskiq.utils import maybe_awaitable
2425

2526
logger = getLogger(__name__)
27+
PY_VERSION = sys.version_info
2628
QUEUE_DONE = b"-1"
2729

2830

@@ -224,6 +226,11 @@ async def run_task( # noqa: C901, PLR0912, PLR0915
224226
# Start a timer.
225227
start_time = time()
226228

229+
check_coroutine_func = (
230+
asyncio.iscoroutinefunction
231+
if PY_VERSION <= (3, 13)
232+
else inspect.iscoroutinefunction
233+
)
227234
try:
228235
# We put kwargs resolving here,
229236
# to be able to catch any exception (for example ),
@@ -234,7 +241,7 @@ async def run_task( # noqa: C901, PLR0912, PLR0915
234241
kwargs.update(message.kwargs)
235242
is_coroutine = True
236243
# If the function is a coroutine, we await it.
237-
if asyncio.iscoroutinefunction(target):
244+
if check_coroutine_func(target):
238245
target_future = target(*message.args, **kwargs)
239246
else:
240247
is_coroutine = False

0 commit comments

Comments
 (0)