File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77from importlib import import_module , invalidate_caches as invalidate_import_caches
88from 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
12271222def _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 )
You can’t perform that action at this time.
0 commit comments