|
56 | 56 | Z = TypeVar("Z", bound="A") |
57 | 57 | S = TypeVar("S", bound="miss") # type: ignore # miss not defined on purpose # noqa: F821 |
58 | 58 | W = NewType("W", str) |
| 59 | +P = typing_extensions.ParamSpec("P") |
| 60 | +P_co = typing_extensions.ParamSpec("P_co", covariant=True) # type: ignore |
| 61 | +P_contra = typing_extensions.ParamSpec("P_contra", contravariant=True) # type: ignore |
| 62 | +P_bound = typing_extensions.ParamSpec("P_bound", bound=str) # type: ignore |
59 | 63 |
|
60 | 64 | # Mypy does not support recursive type aliases, but |
61 | 65 | # other type checkers do. |
@@ -239,6 +243,11 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t |
239 | 243 | (Y, ":py:class:`~typing.TypeVar`\\(``Y``, bound= :py:class:`str`)"), |
240 | 244 | (Z, ":py:class:`~typing.TypeVar`\\(``Z``, bound= A)"), |
241 | 245 | (S, ":py:class:`~typing.TypeVar`\\(``S``, bound= miss)"), |
| 246 | + # ParamSpec should behave like TypeVar, except for missing constraints |
| 247 | + (P, ":py:class:`~typing.ParamSpec`\\(``P``)"), |
| 248 | + (P_co, ":py:class:`~typing.ParamSpec`\\(``P_co``, covariant=True)"), |
| 249 | + (P_contra, ":py:class:`~typing.ParamSpec`\\(``P_contra``, contravariant=True)"), |
| 250 | + (P_bound, ":py:class:`~typing.ParamSpec`\\(``P_bound``, bound= :py:class:`str`)"), |
242 | 251 | # ## These test for correct internal tuple rendering, even if not all are valid Tuple types |
243 | 252 | # Zero-length tuple remains |
244 | 253 | (Tuple[()], ":py:data:`~typing.Tuple`"), |
|
0 commit comments