Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve typehints in lock.py #434

Merged
merged 2 commits into from
Jan 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions aiocache/lock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import uuid

from typing import Type, Union, Any
from typing import Union, Any

from aiocache.base import BaseCache

Expand Down Expand Up @@ -63,7 +63,7 @@ class RedLock:

_EVENTS = {}

def __init__(self, client: Type[BaseCache], key: str, lease: Union[int, float]):
def __init__(self, client: BaseCache, key: str, lease: Union[int, float]):
self.client = client
self.key = self.client._build_key(key + "-lock")
self.lease = lease
Expand Down Expand Up @@ -134,7 +134,7 @@ class OptimisticLock:
If the lock is created with an unexisting key, there will never be conflicts.
"""

def __init__(self, client: Type[BaseCache], key: str):
def __init__(self, client: BaseCache, key: str):
self.client = client
self.key = key
self.ns_key = self.client._build_key(key)
Expand All @@ -150,7 +150,7 @@ async def _acquire(self):
async def __aexit__(self, exc_type, exc_value, traceback):
pass

async def cas(self, value: Any, **kwargs) -> True:
async def cas(self, value: Any, **kwargs) -> bool:
"""
Checks and sets the specified value for the locked key. If the value has changed
since the lock was created, it will raise an :class:`aiocache.lock.OptimisticLockError`
Expand Down