mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
[mypy] Enforcing typing for superset.utils (#9905)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
@@ -14,14 +14,14 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from typing import Callable, Optional
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
from flask import request
|
||||
|
||||
from superset.extensions import cache_manager
|
||||
|
||||
|
||||
def view_cache_key(*_, **__) -> str:
|
||||
def view_cache_key(*args: Any, **kwargs: Any) -> str: # pylint: disable=unused-argument
|
||||
args_hash = hash(frozenset(request.args.items()))
|
||||
return "view/{}/{}".format(request.path, args_hash)
|
||||
|
||||
@@ -45,10 +45,10 @@ def memoized_func(
|
||||
returns the caching key.
|
||||
"""
|
||||
|
||||
def wrap(f):
|
||||
def wrap(f: Callable) -> Callable:
|
||||
if cache_manager.tables_cache:
|
||||
|
||||
def wrapped_f(self, *args, **kwargs):
|
||||
def wrapped_f(self: Any, *args: Any, **kwargs: Any) -> Any:
|
||||
if not kwargs.get("cache", True):
|
||||
return f(self, *args, **kwargs)
|
||||
|
||||
@@ -69,7 +69,7 @@ def memoized_func(
|
||||
|
||||
else:
|
||||
# noop
|
||||
def wrapped_f(self, *args, **kwargs):
|
||||
def wrapped_f(self: Any, *args: Any, **kwargs: Any) -> Any:
|
||||
return f(self, *args, **kwargs)
|
||||
|
||||
return wrapped_f
|
||||
|
||||
Reference in New Issue
Block a user