[mypy] Enforcing typing for superset.utils (#9905)

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley
2020-05-27 22:57:30 -07:00
committed by GitHub
parent 54dced1cf6
commit b296a0f250
17 changed files with 194 additions and 148 deletions

View File

@@ -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