|
9 | 9 | from io import StringIO
|
10 | 10 | from pathlib import Path
|
11 | 11 | from textwrap import dedent, indent
|
12 |
| -from types import FunctionType, ModuleType |
| 12 | +from types import EllipsisType, FrameType, FunctionType, ModuleType, NotImplementedType, TracebackType |
13 | 13 | from typing import ( # noqa: UP035
|
14 | 14 | IO,
|
15 | 15 | Any,
|
@@ -168,8 +168,12 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
|
168 | 168 | pytest.param(str, ":py:class:`str`", id="str"),
|
169 | 169 | pytest.param(int, ":py:class:`int`", id="int"),
|
170 | 170 | pytest.param(StringIO, ":py:class:`~io.StringIO`", id="StringIO"),
|
171 |
| - pytest.param(FunctionType, ":py:class:`~types.FunctionType`", id="FunctionType"), |
| 171 | + pytest.param(EllipsisType, ":py:data:`~types.EllipsisType`", id="EllipsisType"), |
| 172 | + pytest.param(FunctionType, ":py:data:`~types.FunctionType`", id="FunctionType"), |
| 173 | + pytest.param(FrameType, ":py:data:`~types.FrameType`", id="FrameType"), |
172 | 174 | pytest.param(ModuleType, ":py:class:`~types.ModuleType`", id="ModuleType"),
|
| 175 | + pytest.param(NotImplementedType, ":py:data:`~types.NotImplementedType`", id="NotImplementedType"), |
| 176 | + pytest.param(TracebackType, ":py:class:`~types.TracebackType`", id="TracebackType"), |
173 | 177 | pytest.param(type(None), ":py:obj:`None`", id="type None"),
|
174 | 178 | pytest.param(type, ":py:class:`type`", id="type"),
|
175 | 179 | pytest.param(Callable, ":py:class:`~collections.abc.Callable`", id="abc-Callable"),
|
@@ -414,7 +418,7 @@ def test_format_annotation(inv: Inventory, annotation: Any, expected_result: str
|
414 | 418 | assert format_annotation(annotation, conf) == expected_result
|
415 | 419 |
|
416 | 420 | # Test for the correct role (class vs data) using the official Sphinx inventory
|
417 |
| - if "typing" in expected_result: |
| 421 | + if any(modname in expected_result for modname in ("typing", "types")): |
418 | 422 | m = re.match(r"^:py:(?P<role>class|data|func):`~(?P<name>[^`]+)`", result)
|
419 | 423 | assert m, "No match"
|
420 | 424 | name = m.group("name")
|
|
0 commit comments