Skip to content

Commit

Permalink
gh-111729: update generic syntax for typing.Concatenate sample code…
Browse files Browse the repository at this point in the history
… in `Doc/library/typing.rst` (#111734)

use new generic syntax
  • Loading branch information
CubeSugarCheese committed Nov 7, 2023
1 parent 3e99c9c commit c3e19c3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c3e19c3

Please sign in to comment.