File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -716,14 +716,26 @@ def signature(
716716 if type_aliases is None :
717717 type_aliases = {}
718718
719+ # Python 3.14 added the annotationlib module to the standard library as well as the
720+ # 'annotation_format' keyword parameter to inspect.signature(), which allows us to handle
721+ # forward references more robustly.
722+ try :
723+ import annotationlib
724+
725+ inspect_signature_extra = {'annotation_format' : annotationlib .Format .FORWARDREF }
726+ except ImportError :
727+ inspect_signature_extra = {}
728+
719729 try :
720730 if _should_unwrap (subject ):
721- signature = inspect .signature (subject ) # type: ignore[arg-type]
731+ signature = inspect .signature (subject , ** inspect_signature_extra ) # type: ignore[arg-type]
722732 else :
723- signature = inspect .signature (subject , follow_wrapped = True ) # type: ignore[arg-type]
733+ signature = inspect .signature (
734+ subject , follow_wrapped = True , ** inspect_signature_extra
735+ ) # type: ignore[arg-type]
724736 except ValueError :
725737 # follow built-in wrappers up (ex. functools.lru_cache)
726- signature = inspect .signature (subject ) # type: ignore[arg-type]
738+ signature = inspect .signature (subject , ** inspect_signature_extra ) # type: ignore[arg-type]
727739 parameters = list (signature .parameters .values ())
728740 return_annotation = signature .return_annotation
729741
You can’t perform that action at this time.
0 commit comments