Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#372)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Jul 17, 2023
1 parent 55b62de commit 89988e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.277"
rev: "v0.0.278"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/tox-dev/tox-ini-fmt
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_autodoc_typehints/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def napoleon_numpy_docstring_return_type_processor( # noqa: PLR0913
# Underline detection.
chars = set(lines[pos + 1].strip())
# Napoleon allows the underline to consist of a bunch of weirder things...
if len(chars) != 1 or list(chars)[0] not in "=-~_*+#":
if len(chars) != 1 or next(iter(chars)) not in "=-~_*+#":
continue
pos = pos + 2 # noqa: PLW2901
break
Expand Down
25 changes: 13 additions & 12 deletions tests/test_sphinx_autodoc_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
nptyping = None # type: ignore[assignment]

T = TypeVar("T")
U = TypeVar("U", covariant=True)
V = TypeVar("V", contravariant=True)
U_co = TypeVar("U_co", covariant=True)
V_contra = TypeVar("V_contra", contravariant=True)
X = TypeVar("X", str, int)
Y = TypeVar("Y", bound=str)
Z = TypeVar("Z", bound="A")
Expand Down Expand Up @@ -211,13 +211,14 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
":py:class:`~typing.Mapping`\\[:py:class:`~typing.TypeVar`\\(``T``), :py:class:`int`]",
),
(
Mapping[str, V], # type: ignore[valid-type]
":py:class:`~typing.Mapping`\\[:py:class:`str`, :py:class:`~typing.TypeVar`\\(``V``, contravariant=True)]",
Mapping[str, V_contra], # type: ignore[valid-type]
":py:class:`~typing.Mapping`\\[:py:class:`str`, :py:class:`~typing.TypeVar`\\("
"``V_contra``, contravariant=True)]",
),
(
Mapping[T, U], # type: ignore[valid-type]
Mapping[T, U_co], # type: ignore[valid-type]
":py:class:`~typing.Mapping`\\[:py:class:`~typing.TypeVar`\\(``T``), "
":py:class:`~typing.TypeVar`\\(``U``, covariant=True)]",
":py:class:`~typing.TypeVar`\\(``U_co``, covariant=True)]",
),
(Mapping[str, bool], ":py:class:`~typing.Mapping`\\[:py:class:`str`, :py:class:`bool`]"),
(Dict, ":py:class:`~typing.Dict`"),
Expand All @@ -226,13 +227,13 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
":py:class:`~typing.Dict`\\[:py:class:`~typing.TypeVar`\\(``T``), :py:class:`int`]",
),
(
Dict[str, V], # type: ignore[valid-type]
":py:class:`~typing.Dict`\\[:py:class:`str`, :py:class:`~typing.TypeVar`\\(``V``, contravariant=True)]",
Dict[str, V_contra], # type: ignore[valid-type]
":py:class:`~typing.Dict`\\[:py:class:`str`, :py:class:`~typing.TypeVar`\\(``V_contra``, contravariant=True)]",
),
(
Dict[T, U], # type: ignore[valid-type]
Dict[T, U_co], # type: ignore[valid-type]
":py:class:`~typing.Dict`\\[:py:class:`~typing.TypeVar`\\(``T``),"
" :py:class:`~typing.TypeVar`\\(``U``, covariant=True)]",
" :py:class:`~typing.TypeVar`\\(``U_co``, covariant=True)]",
),
(Dict[str, bool], ":py:class:`~typing.Dict`\\[:py:class:`str`, :py:class:`bool`]"),
(Tuple, ":py:data:`~typing.Tuple`"),
Expand Down Expand Up @@ -283,8 +284,8 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t
(E[int], ":py:class:`~%s.E`\\[:py:class:`int`]" % __name__),
(W, f":py:{'class' if PY310_PLUS else 'func'}:`~typing.NewType`\\(``W``, :py:class:`str`)"),
(T, ":py:class:`~typing.TypeVar`\\(``T``)"),
(U, ":py:class:`~typing.TypeVar`\\(``U``, covariant=True)"),
(V, ":py:class:`~typing.TypeVar`\\(``V``, contravariant=True)"),
(U_co, ":py:class:`~typing.TypeVar`\\(``U_co``, covariant=True)"),
(V_contra, ":py:class:`~typing.TypeVar`\\(``V_contra``, contravariant=True)"),
(X, ":py:class:`~typing.TypeVar`\\(``X``, :py:class:`str`, :py:class:`int`)"),
(Y, ":py:class:`~typing.TypeVar`\\(``Y``, bound= :py:class:`str`)"),
(Z, ":py:class:`~typing.TypeVar`\\(``Z``, bound= A)"),
Expand Down

0 comments on commit 89988e6

Please sign in to comment.