From 10e5e405f054ebb6794ed5ff7e4445686bd8e2da Mon Sep 17 00:00:00 2001 From: Jacob Magnusson Date: Mon, 29 Mar 2021 16:41:52 +0200 Subject: [PATCH] Fix mypy typing errors --- fastapi_security/api.py | 6 +++--- fastapi_security/permissions.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fastapi_security/api.py b/fastapi_security/api.py index 50d7c10..1cbc2b3 100644 --- a/fastapi_security/api.py +++ b/fastapi_security/api.py @@ -1,5 +1,5 @@ import logging -from typing import Callable, Iterable, List, Optional, Type +from typing import Callable, Dict, Iterable, List, Optional, Type from fastapi import Depends, HTTPException from fastapi.security.http import HTTPAuthorizationCredentials @@ -27,7 +27,7 @@ def __init__(self, *, user_permission_class: Type[UserPermission] = UserPermissi self.basic_auth = BasicAuthValidator() self.oauth2_jwt = Oauth2JwtAccessTokenValidator() self.oidc_discovery = OpenIdConnectDiscovery() - self._permission_overrides: PermissionOverrides = {} + self._permission_overrides: Dict[str, List[str]] = {} self._user_permission_class = user_permission_class self._all_permissions: List[UserPermission] = [] self._oauth2_init_through_oidc = False @@ -77,7 +77,7 @@ def add_permission_overrides(self, overrides: PermissionOverrides): """ for user, val in overrides.items(): - lst = self._permission_overrides.setdefault(user, []) + lst: List[str] = self._permission_overrides.setdefault(user, []) if isinstance(val, str): assert ( val == "*" diff --git a/fastapi_security/permissions.py b/fastapi_security/permissions.py index 24e03c7..2982ca3 100644 --- a/fastapi_security/permissions.py +++ b/fastapi_security/permissions.py @@ -1,9 +1,9 @@ -from typing import Dict, Iterable, Union +from typing import Dict, MutableSequence, Union __all__ = ("PermissionOverrides",) -PermissionOverrides = Dict[str, Union[str, Iterable[str]]] +PermissionOverrides = Dict[str, Union[str, MutableSequence[str]]] class UserPermission: