mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-128184: Fix display of signatures with ForwardRefs (#130815)
Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
parent
80e6d3ec49
commit
1d251b8339
5 changed files with 46 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue