Skip to content

Commit 3514184

Browse files
[3.12] gh-111729: update generic syntax for typing.Concatenate sample code in Doc/library/typing.rst (GH-111734) (#111814)
(cherry picked from commit c3e19c3) Co-authored-by: 方糖 <[email protected]>
1 parent c4e524c commit 3514184

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Doc/library/typing.rst

+2-5
Original file line numberDiff line numberDiff line change
@@ -1135,16 +1135,13 @@ These can be used as types in annotations. They all support subscription using
11351135

11361136
from collections.abc import Callable
11371137
from threading import Lock
1138-
from typing import Concatenate, ParamSpec, TypeVar
1139-
1140-
P = ParamSpec('P')
1141-
R = TypeVar('R')
1138+
from typing import Concatenate
11421139

11431140
# Use this lock to ensure that only one thread is executing a function
11441141
# at any time.
11451142
my_lock = Lock()
11461143

1147-
def with_lock(f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]:
1144+
def with_lock[**P, R](f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]:
11481145
'''A type-safe decorator which provides a lock.'''
11491146
def inner(*args: P.args, **kwargs: P.kwargs) -> R:
11501147
# Provide the lock as the first argument.

0 commit comments

Comments
 (0)