From 9045a28a4e0a3a5e7ccc8d23fe2e069049a4f06f Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sat, 9 Jan 2021 09:54:51 +0800 Subject: [PATCH 1/3] Paramspec -> typevar --- Doc/library/typing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index c14c7108133819..3b4dba3e0e0a9d 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. From 65c17cbe90691babd671cfc2bf1e9823fe64800e Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sat, 9 Jan 2021 10:02:23 +0800 Subject: [PATCH 2/3] paramspec isn't actually keyword only --- Doc/library/typing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 3b4dba3e0e0a9d..0f6ca9a61caaa6 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -1000,7 +1000,7 @@ These are not used in annotations. They are building blocks for creating generic for the type variable must be a subclass of the boundary type, see :pep:`484`. -.. class:: ParamSpec(name, *, bound=None, covariant=False, contravariant=False) +.. class:: ParamSpec(name, bound=None, covariant=False, contravariant=False) Parameter specification variable. A specialized version of :class:`type variables `. From bb5848015c70a63afb3c70a090721e67a96da78e Mon Sep 17 00:00:00 2001 From: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sun, 10 Jan 2021 11:41:33 +0800 Subject: [PATCH 3/3] enforce keyword only arguments --- Doc/library/typing.rst | 2 +- Lib/typing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 0f6ca9a61caaa6..3b4dba3e0e0a9d 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -1000,7 +1000,7 @@ These are not used in annotations. They are building blocks for creating generic for the type variable must be a subclass of the boundary type, see :pep:`484`. -.. class:: ParamSpec(name, bound=None, covariant=False, contravariant=False) +.. class:: ParamSpec(name, *, bound=None, covariant=False, contravariant=False) Parameter specification variable. A specialized version of :class:`type variables `. diff --git a/Lib/typing.py b/Lib/typing.py index 88d0d623a421f2..6224930c3b0275 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -779,7 +779,7 @@ def add_two(x: float, y: float) -> float: 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: