diff options
author | 方糖 <cubesugarcheese@qq.com> | 2023-11-07 00:53:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-07 00:53:17 (GMT) |
commit | c3e19c3a62e82b9e77563e934059895b6230de6e (patch) | |
tree | d5662e9f4702804a853236bb11525c8a16601012 /Doc | |
parent | 3e99c9cbf67225ec1d3bb6af812e883f19ef53de (diff) | |
download | cpython-c3e19c3a62e82b9e77563e934059895b6230de6e.zip cpython-c3e19c3a62e82b9e77563e934059895b6230de6e.tar.gz cpython-c3e19c3a62e82b9e77563e934059895b6230de6e.tar.bz2 |
gh-111729: update generic syntax for `typing.Concatenate` sample code in `Doc/library/typing.rst` (#111734)
use new generic syntax
Diffstat (limited to 'Doc')
-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 f82f535..a4767d2 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -1145,16 +1145,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. |