Skip to content

Commit 2b7d248

Browse files
authored
Change formatting of 'None'. (#154)
None is now a link to the builtin "None".
1 parent 4bfb14b commit 2b7d248

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sphinx_autodoc_typehints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_annotation_args(annotation, module: str, class_name: str) -> Tuple:
9898
def format_annotation(annotation, fully_qualified: bool = False) -> str:
9999
# Special cases
100100
if annotation is None or annotation is type(None): # noqa: E721
101-
return '``None``'
101+
return ':py:obj:`None`'
102102
elif annotation is Ellipsis:
103103
return '...'
104104

tests/test_sphinx_autodoc_typehints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_parse_annotation(annotation, module, class_name, args):
9898
@pytest.mark.parametrize('annotation, expected_result', [
9999
(str, ':py:class:`str`'),
100100
(int, ':py:class:`int`'),
101-
(type(None), '``None``'),
101+
(type(None), ':py:obj:`None`'),
102102
(type, ':py:class:`type`'),
103103
(Type, ':py:class:`~typing.Type`'),
104104
(Type[A], ':py:class:`~typing.Type`\\[:py:class:`~%s.A`]' % __name__),
@@ -138,7 +138,7 @@ def test_parse_annotation(annotation, module, class_name, args):
138138
(Callable[[int, str], bool], ':py:data:`~typing.Callable`\\[\\[:py:class:`int`, '
139139
':py:class:`str`], :py:class:`bool`]'),
140140
(Callable[[int, str], None], ':py:data:`~typing.Callable`\\[\\[:py:class:`int`, '
141-
':py:class:`str`], ``None``]'),
141+
':py:class:`str`], :py:obj:`None`]'),
142142
(Callable[[T], T], ':py:data:`~typing.Callable`\\[\\[\\~T], \\~T]'),
143143
(Pattern, ':py:class:`~typing.Pattern`'),
144144
(Pattern[str], ':py:class:`~typing.Pattern`\\[:py:class:`str`]'),

0 commit comments

Comments
 (0)