mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #6592 from tk0miya/6589_autodoc_typehints_none
Fix #6589: autodoc: Formatting issues with autodoc_typehints='none'
This commit is contained in:
commit
04fbd51b4e
1
CHANGES
1
CHANGES
@ -50,6 +50,7 @@ Bugs fixed
|
||||
``__init__()`` and ``__new__()``
|
||||
* #6574: autodoc: :confval:`autodoc_member_order` does not refer order of
|
||||
imports when ``'bysource'`` order
|
||||
* #6589: autodoc: Formatting issues with autodoc_typehints='none'
|
||||
* #6498: autosummary: crashed with wrong autosummary_generate setting
|
||||
* #6507: autosummary: crashes without no autosummary_generate setting
|
||||
* #6511: LaTeX: autonumbered list can not be customized in LaTeX
|
||||
|
@ -428,7 +428,7 @@ class Signature:
|
||||
arg.write(': ')
|
||||
arg.write(self.format_annotation(param.annotation))
|
||||
if param.default is not param.empty:
|
||||
if param.annotation is param.empty:
|
||||
if param.annotation is param.empty or show_annotation is False:
|
||||
arg.write('=')
|
||||
arg.write(object_description(param.default))
|
||||
else:
|
||||
@ -444,7 +444,7 @@ class Signature:
|
||||
args.append(arg.getvalue())
|
||||
last_kind = param.kind
|
||||
|
||||
if self.return_annotation is inspect.Parameter.empty:
|
||||
if self.return_annotation is inspect.Parameter.empty or show_annotation is False:
|
||||
return '(%s)' % ', '.join(args)
|
||||
else:
|
||||
if 'return' in self.annotations:
|
||||
|
@ -501,15 +501,15 @@ def test_autodoc_typehints_none(app):
|
||||
'.. py:module:: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: Math(s, o = None)',
|
||||
'.. py:class:: Math(s, o=None)',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
' ',
|
||||
' .. py:method:: Math.incr(a, b = 1) -> int',
|
||||
' .. py:method:: Math.incr(a, b=1)',
|
||||
' :module: target.typehints',
|
||||
' ',
|
||||
'',
|
||||
'.. py:function:: incr(a, b = 1) -> int',
|
||||
'.. py:function:: incr(a, b=1)',
|
||||
' :module: target.typehints',
|
||||
''
|
||||
]
|
||||
|
@ -285,6 +285,10 @@ def test_Signature_annotations():
|
||||
sig = inspect.Signature(Node.__init__).format_args()
|
||||
assert sig == '(self, parent: Optional[Node]) -> None'
|
||||
|
||||
# show_annotation is False
|
||||
sig = inspect.Signature(f7).format_args(show_annotation=False)
|
||||
assert sig == '(x=None, y={})'
|
||||
|
||||
|
||||
def test_safe_getattr_with_default():
|
||||
class Foo:
|
||||
|
Loading…
Reference in New Issue
Block a user