gh-128184: Fix display of signatures with ForwardRefs (#130815)

Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
Jelle Zijlstra 2025-03-04 06:58:37 -08:00 committed by GitHub
parent 80e6d3ec49
commit 1d251b8339
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 46 additions and 2 deletions

View file

@ -143,7 +143,7 @@ __all__ = [
import abc
from annotationlib import Format
from annotationlib import Format, ForwardRef
from annotationlib import get_annotations # re-exported
import ast
import dis
@ -1342,6 +1342,8 @@ def formatannotation(annotation, base_module=None, *, quote_annotation_strings=T
if annotation.__module__ in ('builtins', base_module):
return annotation.__qualname__
return annotation.__module__+'.'+annotation.__qualname__
if isinstance(annotation, ForwardRef):
return annotation.__forward_arg__
return repr(annotation)
def formatannotationrelativeto(object):