mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
change format_args to prefer annotations from typing.get_type_hints
The current code looks for the pattern::
class Node:
def parent(self) -> 'Node': pass
This change allows more complex forward references::
class Node:
def children(self) -> Set['Node']: pass
This commit is contained in:
committed by
Terence D. Honles
parent
8a23ad1f44
commit
742c89f99b
@@ -433,8 +433,7 @@ class Signature(object):
|
||||
if PY2 or self.return_annotation is inspect.Parameter.empty:
|
||||
return '(%s)' % ', '.join(args)
|
||||
else:
|
||||
if isinstance(self.return_annotation, string_types) and \
|
||||
'return' in self.annotations:
|
||||
if 'return' in self.annotations:
|
||||
annotation = self.format_annotation(self.annotations['return'])
|
||||
else:
|
||||
annotation = self.format_annotation(self.return_annotation)
|
||||
|
||||
Reference in New Issue
Block a user