From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Mon, 11 Jan 2021 00:11:41 +0000 (+0800) Subject: Fix various ParamSpec errors in typing (GH-24176) X-Git-Tag: v3.10.0a5~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ace008c531dd685a30c1dd68f9b5ba35f20171cf;p=thirdparty%2FPython%2Fcpython.git Fix various ParamSpec errors in typing (GH-24176) 1. ParamSpec -> TypeVar for ``typing.Concatenate`` 2. ParamSpec's call signature should align with its documentation. Noticed in GH-24169 --- diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index c14c71081338..3b4dba3e0e0a 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -695,10 +695,10 @@ These can be used as types in annotations using ``[]``, each having a unique syn from collections.abc import Callable from threading import Lock - from typing import Any, Concatenate, ParamSpec + from typing import Any, Concatenate, ParamSpec, TypeVar P = ParamSpec('P') - R = ParamSpec('R') + R = TypeVar('R') # Use this lock to ensure that only one thread is executing a function # at any time. diff --git a/Lib/typing.py b/Lib/typing.py index 88d0d623a421..6224930c3b02 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -779,7 +779,7 @@ class ParamSpec(_Final, _Immutable, _TypeVarLike, _root=True): args = object() kwargs = object() - def __init__(self, name, bound=None, covariant=False, contravariant=False): + def __init__(self, name, *, bound=None, covariant=False, contravariant=False): self.__name__ = name super().__init__(bound, covariant, contravariant) try: