Skip to content

Commit 9310840

Browse files
committed
Fix iscoroutinefunction import for older Pythons
1 parent 05a5e7d commit 9310840

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/dependency_injector/providers.pyx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from __future__ import absolute_import
55
import builtins
66
import errno
77
import sys
8-
from asyncio import Future, ensure_future, gather, iscoroutinefunction
8+
from asyncio import Future, ensure_future, gather
99
from configparser import ConfigParser as IniConfigParser
1010
from contextlib import asynccontextmanager, contextmanager
1111
from contextvars import ContextVar
@@ -142,8 +142,8 @@ try:
142142

143143
__COROUTINE_TYPES = _COROUTINE_TYPES
144144
except ImportError:
145-
from types import CoroutineType
146145
from collections.abc import Coroutine as ABCCoroutine
146+
from types import CoroutineType
147147

148148
__COROUTINE_TYPES = (CoroutineType, ABCCoroutine)
149149

@@ -4968,21 +4968,10 @@ def traverse(*providers, types=None):
49684968

49694969
yield visiting
49704970

4971-
4972-
def always_return_false(*a, **kw):
4973-
return False
4974-
4975-
4976-
try:
4977-
from inspect import isawaitable
4978-
except ImportError:
4979-
isawaitable = always_return_false
4980-
4981-
try:
4971+
if sys.version_info >= (3, 11):
49824972
from inspect import iscoroutinefunction
4983-
except ImportError:
4984-
iscoroutinefunction = always_return_false
4985-
4973+
else:
4974+
from asyncio import iscoroutinefunction
49864975

49874976
def _resolve_string_import(provides):
49884977
if provides is None:

0 commit comments

Comments
 (0)