]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix various ParamSpec errors in typing (GH-24176)
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Mon, 11 Jan 2021 00:11:41 +0000 (08:11 +0800)
committerGitHub <noreply@github.com>
Mon, 11 Jan 2021 00:11:41 +0000 (16:11 -0800)
1. ParamSpec -> TypeVar for ``typing.Concatenate``
2. ParamSpec's call signature should align with its documentation.
Noticed in GH-24169

Doc/library/typing.rst
Lib/typing.py

index c14c71081338190eb110e2eb0c4ab475a0c2038b..3b4dba3e0e0a9ddae8da1ab54685ed5704e33ac8 100644 (file)
@@ -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.
index 88d0d623a421f2166aa901d3c516f12edb6dca59..6224930c3b0275fc5cfdc4e73fd32283f8a272b6 100644 (file)
@@ -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: