mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
redis: include local property on Lock class (#6083)
The Lock class as a property local that has a token property that sometimes needs be accessed / set. ```python lock = redis.lock(key) lock.local.token = token lock.extend(10) ``` Technically the type of `local` is `SimpleNamespace | threading.local` but I think this setup is a bit stricter but satisfies the API.
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
from types import TracebackType
|
||||
from typing import Any, Text, Type, Union
|
||||
from typing_extensions import Protocol
|
||||
|
||||
from redis.client import Redis
|
||||
|
||||
_TokenValue = Union[bytes, Text]
|
||||
|
||||
class _Local(Protocol):
|
||||
token: _TokenValue | None
|
||||
|
||||
class Lock:
|
||||
local: _Local
|
||||
def __init__(
|
||||
self,
|
||||
redis: Redis[Any],
|
||||
|
||||
Reference in New Issue
Block a user