style(mypy): Fix memoize watch type (#9970)

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley 2020-06-02 16:02:07 -07:00 committed by GitHub
parent fc92692f49
commit 15f267d586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -281,7 +281,7 @@ class Database(
effective_username = g.user.username
return effective_username
@utils.memoized(watch=["impersonate_user", "sqlalchemy_uri_decrypted", "extra"])
@utils.memoized(watch=("impersonate_user", "sqlalchemy_uri_decrypted", "extra"))
def get_sqla_engine(
self,
schema: Optional[str] = None,

View File

@ -147,11 +147,11 @@ class _memoized:
should account for instance variable changes.
"""
def __init__(self, func: Callable, watch: Optional[List[str]] = None) -> None:
def __init__(self, func: Callable, watch: Optional[Tuple[str, ...]] = None) -> None:
self.func = func
self.cache: Dict[Any, Any] = {}
self.is_method = False
self.watch = watch or []
self.watch = watch or ()
def __call__(self, *args: Any, **kwargs: Any) -> Any:
key = [args, frozenset(kwargs.items())]
@ -181,7 +181,7 @@ class _memoized:
def memoized(
func: Optional[Callable] = None, watch: Optional[List[str]] = None
func: Optional[Callable] = None, watch: Optional[Tuple[str, ...]] = None
) -> Callable:
if func:
return _memoized(func)