Skip to content

Commit 05a5e7d

Browse files
committed
Fix get_annotations import
1 parent 58700d9 commit 05a5e7d

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

src/dependency_injector/wiring.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from importlib import import_module, invalidate_caches as invalidate_import_caches
88
from inspect import (
99
Parameter,
10-
get_annotations,
1110
getmembers,
1211
isasyncgenfunction,
1312
isbuiltin,
@@ -1213,20 +1212,16 @@ def _patched(*args: Any, **raw_kwargs: Any) -> Any:
12131212
return cast(F, _patched)
12141213

12151214

1216-
if sys.version_info >= (3, 10):
1217-
1218-
def _get_annotations(obj: Any) -> Dict[str, Any]:
1219-
return get_annotations(obj)
1220-
1221-
else:
1222-
1223-
def _get_annotations(obj: Any) -> Dict[str, Any]:
1215+
try:
1216+
from inspect import get_annotations
1217+
except ImportError:
1218+
def get_annotations(obj: Any) -> Dict[str, Any]:
12241219
return getattr(obj, "__annotations__", {})
12251220

12261221

12271222
def _get_members_and_annotated(obj: Any) -> Iterable[Tuple[str, Any]]:
12281223
members = getmembers(obj)
1229-
annotations = _get_annotations(obj)
1224+
annotations = get_annotations(obj)
12301225
for annotation_name, annotation in annotations.items():
12311226
if get_origin(annotation) is Annotated:
12321227
args = get_args(annotation)

0 commit comments

Comments
 (0)