diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-11-07 01:00:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-07 01:00:16 (GMT) |
commit | 35141842d350bfa2c8dc04e7cc886bdff03cf3b7 (patch) | |
tree | 7370c73f2918cc1150fea523f53278f2aaa709e0 | |
parent | c4e524c3f25bb9b58427b0eb58d24989d81a2663 (diff) | |
download | cpython-35141842d350bfa2c8dc04e7cc886bdff03cf3b7.zip cpython-35141842d350bfa2c8dc04e7cc886bdff03cf3b7.tar.gz cpython-35141842d350bfa2c8dc04e7cc886bdff03cf3b7.tar.bz2 |
[3.12] gh-111729: update generic syntax for `typing.Concatenate` sample code in `Doc/library/typing.rst` (GH-111734) (#111814)
(cherry picked from commit c3e19c3a62e82b9e77563e934059895b6230de6e)
Co-authored-by: 方糖 <cubesugarcheese@qq.com>
-rw-r--r-- | Doc/library/typing.rst | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 44665b6..7cec244 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -1135,16 +1135,13 @@ These can be used as types in annotations. They all support subscription using from collections.abc import Callable from threading import Lock - from typing import Concatenate, ParamSpec, TypeVar - - P = ParamSpec('P') - R = TypeVar('R') + from typing import Concatenate # Use this lock to ensure that only one thread is executing a function # at any time. my_lock = Lock() - def with_lock(f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]: + def with_lock[**P, R](f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]: '''A type-safe decorator which provides a lock.''' def inner(*args: P.args, **kwargs: P.kwargs) -> R: # Provide the lock as the first argument. |