Skip to content

Commit

Permalink
Set type of default django.core.cache.cache to BaseCache (#998)
Browse files Browse the repository at this point in the history
* Set type of default `django.core.cache` to `BaseCache`

- The previous type `ConnectionProxy` is just a proxy class, thus
  revealing `Any` for _all_ cache methods

* fixup! Set type of default `django.core.cache` to `BaseCache`
  • Loading branch information
flaeppe authored Jun 16, 2022
1 parent e45ecd6 commit 8d8b8cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion django-stubs/core/cache/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ class CacheHandler(BaseConnectionHandler):

def close_caches(**kwargs: Any) -> None: ...

cache: ConnectionProxy
cache: BaseCache
caches: CacheHandler
26 changes: 14 additions & 12 deletions django-stubs/core/cache/backends/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@ def default_key_func(key: Any, key_prefix: str, version: Any) -> str: ...
def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ...

class BaseCache:
default_timeout: int = ...
default_timeout: Optional[int] = ...
key_prefix: str = ...
version: int = ...
key_func: Callable = ...
def __init__(self, params: Dict[str, Any]) -> None: ...
def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ...
def make_key(self, key: Any, version: Optional[Any] = ...) -> str: ...
def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> bool: ...
def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ...
def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
def touch(self, key: Any, timeout: Any = ..., version: Optional[Any] = ...) -> bool: ...
def delete(self, key: Any, version: Optional[Any] = ...) -> None: ...
def get_backend_timeout(self, timeout: Optional[int] = ...) -> Optional[float]: ...
def make_key(self, key: Any, version: Optional[int] = ...) -> str: ...
def add(self, key: Any, value: Any, timeout: Optional[int] = ..., version: Optional[int] = ...) -> bool: ...
def get(self, key: Any, default: Optional[Any] = ..., version: Optional[int] = ...) -> Any: ...
def set(self, key: Any, value: Any, timeout: Optional[int] = ..., version: Optional[int] = ...) -> None: ...
def touch(self, key: Any, timeout: Optional[int] = ..., version: Optional[int] = ...) -> bool: ...
def delete(self, key: Any, version: Optional[int] = ...) -> None: ...
def get_many(self, keys: Iterable[Any], version: Optional[int] = ...) -> Dict[Any, Any]: ...
def get_or_set(
self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ...
self, key: Any, default: Optional[Any], timeout: Optional[int] = ..., version: Optional[int] = ...
) -> Optional[Any]: ...
def has_key(self, key: Any, version: Optional[Any] = ...) -> bool: ...
def has_key(self, key: Any, version: Optional[int] = ...) -> bool: ...
def incr(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ...
def decr(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ...
def __contains__(self, key: Any) -> bool: ...
def set_many(self, data: Dict[Any, Any], timeout: Any = ..., version: Optional[Any] = ...) -> List[Any]: ...
def delete_many(self, keys: Iterable[Any], version: Optional[Any] = ...) -> None: ...
def set_many(
self, data: Dict[Any, Any], timeout: Optional[int] = ..., version: Optional[int] = ...
) -> List[Any]: ...
def delete_many(self, keys: Iterable[Any], version: Optional[int] = ...) -> None: ...
def clear(self) -> None: ...
def validate_key(self, key: Any) -> None: ...
def incr_version(self, key: Any, delta: int = ..., version: Optional[int] = ...) -> int: ...
Expand Down

0 comments on commit 8d8b8cd

Please sign in to comment.