Skip to content

Commit bd99b06

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 878c5fc commit bd99b06

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import shutil
55
import sys
66
from pathlib import Path
7-
from typing import TYPE_CHECKING, Any
7+
from typing import TYPE_CHECKING
88

99
import pytest
1010
from sphobjinv import Inventory

tests/test_sphinx_autodoc_typehints.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414
IO,
1515
Any,
1616
AnyStr,
17-
Callable,
1817
Dict,
1918
Generic,
2019
List,
21-
Mapping,
22-
Match,
2320
NewType,
2421
Optional,
25-
Pattern,
2622
Tuple,
2723
Type,
2824
TypeVar,
@@ -146,20 +142,20 @@ def __getitem__(self, params): # noqa: ANN001, ANN204
146142
pytest.param(Tuple, "typing", "Tuple", (), id="Tuple"), # noqa: UP006
147143
pytest.param(Tuple[str, int], "typing", "Tuple", (str, int), id="Tuple_parametrized"), # noqa: UP006
148144
pytest.param(Union[str, int], "typing", "Union", (str, int), id="Union"), # noqa: UP007
149-
pytest.param(Callable, "typing", "Callable", (), id="Callable"),
150-
pytest.param(Callable[..., str], "typing", "Callable", (..., str), id="Callable_returntype"),
151-
pytest.param(Callable[[int, str], str], "typing", "Callable", (int, str, str), id="Callable_all_types"),
145+
pytest.param(collections.abc.Callable, "typing", "Callable", (), id="Callable"),
146+
pytest.param(collections.abc.Callable[..., str], "typing", "Callable", (..., str), id="Callable_returntype"),
147+
pytest.param(collections.abc.Callable[[int, str], str], "typing", "Callable", (int, str, str), id="Callable_all_types"),
152148
pytest.param(
153149
AbcCallable[[int, str], str], # type: ignore[type-arg,misc,valid-type]
154150
"collections.abc",
155151
"Callable",
156152
(int, str, str),
157153
id="collections.abc.Callable_all_types",
158154
),
159-
pytest.param(Pattern, "typing", "Pattern", (), id="Pattern"),
160-
pytest.param(Pattern[str], "typing", "Pattern", (str,), id="Pattern_parametrized"),
161-
pytest.param(Match, "typing", "Match", (), id="Match"),
162-
pytest.param(Match[str], "typing", "Match", (str,), id="Match_parametrized"),
155+
pytest.param(re.Pattern, "typing", "Pattern", (), id="Pattern"),
156+
pytest.param(re.Pattern[str], "typing", "Pattern", (str,), id="Pattern_parametrized"),
157+
pytest.param(re.Match, "typing", "Match", (), id="Match"),
158+
pytest.param(re.Match[str], "typing", "Match", (str,), id="Match_parametrized"),
163159
pytest.param(IO, "typing", "IO", (), id="IO"),
164160
pytest.param(W, "typing", "NewType", (str,), id="W"),
165161
pytest.param(P, "typing", "ParamSpec", (), id="P"),
@@ -197,26 +193,26 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
197193
pytest.param(Any, ":py:data:`~typing.Any`", id="Any"),
198194
pytest.param(AnyStr, ":py:data:`~typing.AnyStr`", id="AnyStr"),
199195
pytest.param(Generic[T], r":py:class:`~typing.Generic`\ \[:py:class:`~typing.TypeVar`\ \(``T``)]", id="Generic"),
200-
pytest.param(Mapping, ":py:class:`~typing.Mapping`", id="Mapping"),
196+
pytest.param(collections.abc.Mapping, ":py:class:`~typing.Mapping`", id="Mapping"),
201197
pytest.param(
202-
Mapping[T, int], # type: ignore[valid-type]
198+
collections.abc.Mapping[T, int], # type: ignore[valid-type]
203199
r":py:class:`~typing.Mapping`\ \[:py:class:`~typing.TypeVar`\ \(``T``), :py:class:`int`]",
204200
id="Mapping-T-int",
205201
),
206202
pytest.param(
207-
Mapping[str, V_contra], # type: ignore[valid-type]
203+
collections.abc.Mapping[str, V_contra], # type: ignore[valid-type]
208204
r":py:class:`~typing.Mapping`\ \[:py:class:`str`, :py:class:`~typing.TypeVar`\ \("
209205
"``V_contra``, contravariant=True)]",
210206
id="Mapping-T-int-contra",
211207
),
212208
pytest.param(
213-
Mapping[T, U_co], # type: ignore[valid-type]
209+
collections.abc.Mapping[T, U_co], # type: ignore[valid-type]
214210
r":py:class:`~typing.Mapping`\ \[:py:class:`~typing.TypeVar`\ \(``T``), "
215211
r":py:class:`~typing.TypeVar`\ \(``U_co``, covariant=True)]",
216212
id="Mapping-T-int-co",
217213
),
218214
pytest.param(
219-
Mapping[str, bool],
215+
collections.abc.Mapping[str, bool],
220216
r":py:class:`~typing.Mapping`\ \[:py:class:`str`, :py:class:`bool`]",
221217
id="Mapping-str-bool",
222218
),
@@ -290,29 +286,29 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
290286
r":py:data:`~typing.Union`\ \[:py:class:`str`, :py:class:`bool`, :py:obj:`None`]",
291287
id="Optional-Union-str-bool",
292288
),
293-
pytest.param(Callable, ":py:data:`~typing.Callable`", id="Callable"),
289+
pytest.param(collections.abc.Callable, ":py:data:`~typing.Callable`", id="Callable"),
294290
pytest.param(
295-
Callable[..., int],
291+
collections.abc.Callable[..., int],
296292
r":py:data:`~typing.Callable`\ \[:py:data:`...<Ellipsis>`, :py:class:`int`]",
297293
id="Callable-Ellipsis-int",
298294
),
299295
pytest.param(
300-
Callable[[int], int],
296+
collections.abc.Callable[[int], int],
301297
r":py:data:`~typing.Callable`\ \[\[:py:class:`int`], :py:class:`int`]",
302298
id="Callable-int-int",
303299
),
304300
pytest.param(
305-
Callable[[int, str], bool],
301+
collections.abc.Callable[[int, str], bool],
306302
r":py:data:`~typing.Callable`\ \[\[:py:class:`int`, :py:class:`str`], :py:class:`bool`]",
307303
id="Callable-int-str-bool",
308304
),
309305
pytest.param(
310-
Callable[[int, str], None],
306+
collections.abc.Callable[[int, str], None],
311307
r":py:data:`~typing.Callable`\ \[\[:py:class:`int`, :py:class:`str`], :py:obj:`None`]",
312308
id="Callable-int-str",
313309
),
314310
pytest.param(
315-
Callable[[T], T],
311+
collections.abc.Callable[[T], T],
316312
r":py:data:`~typing.Callable`\ \[\[:py:class:`~typing.TypeVar`\ \(``T``)],"
317313
r" :py:class:`~typing.TypeVar`\ \(``T``)]",
318314
id="Callable-T-T",
@@ -322,8 +318,8 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
322318
r":py:class:`~collections.abc.Callable`\ \[\[:py:class:`int`, :py:class:`str`], :py:class:`bool`]",
323319
id="AbcCallable-int-str-bool",
324320
),
325-
pytest.param(Pattern, ":py:class:`~typing.Pattern`", id="Pattern"),
326-
pytest.param(Pattern[str], r":py:class:`~typing.Pattern`\ \[:py:class:`str`]", id="Pattern-str"),
321+
pytest.param(re.Pattern, ":py:class:`~typing.Pattern`", id="Pattern"),
322+
pytest.param(re.Pattern[str], r":py:class:`~typing.Pattern`\ \[:py:class:`str`]", id="Pattern-str"),
327323
pytest.param(IO, ":py:class:`~typing.IO`", id="IO"),
328324
pytest.param(IO[str], r":py:class:`~typing.IO`\ \[:py:class:`str`]", id="IO-str"),
329325
pytest.param(Metaclass, f":py:class:`~{__name__}.Metaclass`", id="Metaclass"),
@@ -384,6 +380,7 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
384380
),
385381
]
386382

383+
387384
@pytest.mark.parametrize(("annotation", "expected_result"), _CASES)
388385
def test_format_annotation(inv: Inventory, annotation: Any, expected_result: str) -> None:
389386
conf = create_autospec(Config, _annotation_globals=globals(), always_use_bars_union=False)

0 commit comments

Comments
 (0)