Skip to content

Commit

Permalink
Update type annotations for cache proxy class (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybaloney authored Oct 7, 2023
1 parent 196abbf commit f2e7608
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/flask_caching/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@
import uuid
import warnings
from collections import OrderedDict
from typing import Any
from typing import Callable
from typing import Optional
from typing import Tuple
from typing import Union
from typing import Any, Dict, List, Callable, Optional, Tuple, Union

from flask import current_app
from flask import Flask
from flask import request
from flask import Response
from flask import url_for
from markupsafe import Markup
from werkzeug.utils import import_string

from flask_caching.backends.base import BaseCache
Expand Down Expand Up @@ -185,7 +180,7 @@ def cache(self) -> SimpleCache:
app = current_app or self.app
return app.extensions["cache"][self]

def get(self, *args, **kwargs) -> Optional[Union[str, Markup]]:
def get(self, *args, **kwargs) -> Any:
"""Proxy function for internal cache object."""
return self.cache.get(*args, **kwargs)

Expand All @@ -205,7 +200,7 @@ def delete(self, *args, **kwargs) -> bool:
"""Proxy function for internal cache object."""
return self.cache.delete(*args, **kwargs)

def delete_many(self, *args, **kwargs) -> bool:
def delete_many(self, *args, **kwargs) -> List[str]:
"""Proxy function for internal cache object."""
return self.cache.delete_many(*args, **kwargs)

Expand All @@ -217,15 +212,15 @@ def get_many(self, *args, **kwargs):
"""Proxy function for internal cache object."""
return self.cache.get_many(*args, **kwargs)

def set_many(self, *args, **kwargs):
def set_many(self, *args, **kwargs) -> List[Any]:
"""Proxy function for internal cache object."""
return self.cache.set_many(*args, **kwargs)

def get_dict(self, *args, **kwargs):
def get_dict(self, *args, **kwargs) -> Dict[str, Any]:
"""Proxy function for internal cache object."""
return self.cache.get_dict(*args, **kwargs)

def unlink(self, *args, **kwargs) -> bool:
def unlink(self, *args, **kwargs) -> List[str]:
"""Proxy function for internal cache object
only support Redis
"""
Expand Down Expand Up @@ -474,7 +469,7 @@ def _make_cache_key_query_string():

return cache_key

def _make_cache_key(args, kwargs, use_request):
def _make_cache_key(args, kwargs, use_request) -> str:
if query_string:
return _make_cache_key_query_string()
else:
Expand Down

0 comments on commit f2e7608

Please sign in to comment.