Skip to content

Commit ca412e5

Browse files
committed
fix: webauthn email ingredient types, bump pyright
1 parent dd2b009 commit ca412e5

File tree

12 files changed

+40
-41
lines changed

12 files changed

+40
-41
lines changed

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pdoc3==0.11.0
1111
pre-commit==3.5.0
1212
pyfakefs==5.7.4
1313
pylint==3.2.7
14-
pyright==1.1.393
14+
pyright==1.1.402
1515
python-dotenv==1.0.1
1616
pytest==8.3.3
1717
pytest-asyncio==0.24.0

supertokens_python/recipe/emailpassword/api/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# under the License.
1414
from __future__ import annotations
1515

16-
from typing import Any, Dict, List, Union
16+
from typing import Any, Dict, List, Union, cast
1717

1818
from supertokens_python.exceptions import raise_bad_input_exception
1919
from supertokens_python.recipe.emailpassword.constants import (
@@ -78,7 +78,9 @@ async def validate_form_fields_or_throw_error(
7878

7979
form_fields: List[FormField] = []
8080

81-
form_fields_list_raw: List[Dict[str, Any]] = form_fields_raw
81+
form_fields_list_raw: List[Dict[str, Any]] = cast(
82+
List[Dict[str, Any]], form_fields_raw
83+
)
8284
for current_form_field in form_fields_list_raw:
8385
if (
8486
"id" not in current_form_field

supertokens_python/recipe/session/claim_base_classes/primitive_array_claim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15-
from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union
15+
from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union, cast
1616

1717
from supertokens_python.types import MaybeAwaitable, RecipeUserId
1818
from supertokens_python.utils import get_timestamp_ms
@@ -105,7 +105,7 @@ async def _validate(
105105

106106
# Doing this to ensure same code in the upcoming steps irrespective of
107107
# whether self.val is Primitive or PrimitiveList
108-
vals: List[_T] = val if isinstance(val, list) else [val]
108+
vals: List[_T] = cast(List[_T], val if isinstance(val, list) else [val])
109109

110110
claim_val_set = set(claim_val)
111111
if is_include and not is_include_any:

supertokens_python/recipe/thirdparty/providers/apple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import json
1717
from re import sub
1818
from time import time
19-
from typing import Any, Dict, Optional
19+
from typing import Any, Dict, Optional, cast
2020

2121
from jwt import encode # type: ignore
2222

@@ -106,7 +106,7 @@ async def get_user_info(
106106
if isinstance(user, str):
107107
user_dict = json.loads(user)
108108
elif isinstance(user, dict):
109-
user_dict = user
109+
user_dict = cast(Dict[str, Any], user)
110110
else:
111111
return response
112112

supertokens_python/recipe/thirdparty/providers/custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, Dict, List, Optional, Union
1+
from typing import Any, Callable, Dict, List, Optional, Union, cast
22
from urllib.parse import parse_qs, urlencode, urlparse
33

44
import pkce
@@ -67,7 +67,7 @@ def access_field(obj: Any, key: str) -> Any:
6767
key_parts = key.split(".")
6868
for part in key_parts:
6969
if isinstance(obj, dict):
70-
obj = obj.get(part) # type: ignore
70+
obj = cast(Dict[str, Any], obj).get(part)
7171
else:
7272
return None
7373

supertokens_python/recipe/webauthn/interfaces/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15-
from abc import ABC, abstractmethod
16-
from typing import List, Literal, Optional, TypedDict, Union
15+
from abc import abstractmethod
16+
from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict, Union
1717

1818
from typing_extensions import NotRequired, Unpack
1919

supertokens_python/recipe/webauthn/types/config.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import Optional, Protocol, TypeVar, Union, runtime_checkable
1818

1919
from supertokens_python.framework import BaseRequest
20+
from supertokens_python.ingredients.emaildelivery import EmailDeliveryIngredient
2021
from supertokens_python.ingredients.emaildelivery.types import (
2122
EmailDeliveryConfig,
2223
EmailDeliveryConfigWithService,
@@ -192,12 +193,7 @@ class WebauthnConfig(BaseConfig[RecipeInterface, APIInterface]):
192193
get_relying_party_id: Optional[Union[str, GetRelyingPartyId]] = None
193194
get_relying_party_name: Optional[Union[str, GetRelyingPartyName]] = None
194195
get_origin: Optional[GetOrigin] = None
195-
email_delivery: Optional[
196-
Union[
197-
EmailDeliveryConfig[TypeWebauthnEmailDeliveryInput],
198-
EmailDeliveryConfigWithService[TypeWebauthnEmailDeliveryInput],
199-
]
200-
] = None
196+
email_delivery: Optional[EmailDeliveryConfig[TypeWebauthnEmailDeliveryInput]] = None
201197
validate_email_address: Optional[ValidateEmailAddress] = None
202198

203199

@@ -211,8 +207,5 @@ class NormalisedWebauthnConfig(BaseNormalisedConfig[RecipeInterface, APIInterfac
211207

212208
class WebauthnIngredients(CamelCaseBaseModel):
213209
email_delivery: Optional[
214-
Union[
215-
EmailDeliveryConfig[TypeWebauthnEmailDeliveryInput],
216-
EmailDeliveryConfigWithService[TypeWebauthnEmailDeliveryInput],
217-
]
210+
EmailDeliveryIngredient[TypeWebauthnEmailDeliveryInput]
218211
] = None

tests/auth-react/django3x/mysite/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from supertokens_python import InputAppInfo, Supertokens, SupertokensConfig, init
99
from supertokens_python.framework.request import BaseRequest
1010
from supertokens_python.ingredients.emaildelivery.types import (
11-
EmailDeliveryConfigWithService,
11+
EmailDeliveryConfig,
1212
EmailDeliveryInterface,
1313
)
1414
from supertokens_python.recipe import (
@@ -999,9 +999,9 @@ async def resync_session_and_fetch_mfa_info_put(
999999
"id": "webauthn",
10001000
"init": webauthn.init(
10011001
config=WebauthnConfig(
1002-
email_delivery=EmailDeliveryConfigWithService[
1003-
TypeWebauthnEmailDeliveryInput
1004-
](service=CustomWebwuthnEmailService()) # type: ignore
1002+
email_delivery=EmailDeliveryConfig[TypeWebauthnEmailDeliveryInput](
1003+
service=CustomWebwuthnEmailService()
1004+
)
10051005
)
10061006
),
10071007
},

tests/auth-react/fastapi-server/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from supertokens_python.framework.fastapi import get_middleware
4242
from supertokens_python.framework.request import BaseRequest
4343
from supertokens_python.ingredients.emaildelivery.types import (
44-
EmailDeliveryConfigWithService,
44+
EmailDeliveryConfig,
4545
EmailDeliveryInterface,
4646
)
4747
from supertokens_python.recipe import (
@@ -1100,9 +1100,9 @@ async def resync_session_and_fetch_mfa_info_put(
11001100
"id": "webauthn",
11011101
"init": webauthn.init(
11021102
config=WebauthnConfig(
1103-
email_delivery=EmailDeliveryConfigWithService[
1104-
TypeWebauthnEmailDeliveryInput
1105-
](service=CustomWebwuthnEmailService()) # type: ignore
1103+
email_delivery=EmailDeliveryConfig[TypeWebauthnEmailDeliveryInput](
1104+
service=CustomWebwuthnEmailService()
1105+
)
11061106
)
11071107
),
11081108
},

tests/auth-react/flask-server/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from supertokens_python.framework.flask.flask_middleware import Middleware
3333
from supertokens_python.framework.request import BaseRequest
3434
from supertokens_python.ingredients.emaildelivery.types import (
35-
EmailDeliveryConfigWithService,
35+
EmailDeliveryConfig,
3636
EmailDeliveryInterface,
3737
)
3838
from supertokens_python.recipe import (
@@ -1079,9 +1079,9 @@ async def resync_session_and_fetch_mfa_info_put(
10791079
"id": "webauthn",
10801080
"init": webauthn.init(
10811081
config=WebauthnConfig(
1082-
email_delivery=EmailDeliveryConfigWithService[
1083-
TypeWebauthnEmailDeliveryInput
1084-
](service=CustomWebwuthnEmailService()) # type: ignore
1082+
email_delivery=EmailDeliveryConfig[TypeWebauthnEmailDeliveryInput](
1083+
service=CustomWebwuthnEmailService()
1084+
)
10851085
)
10861086
),
10871087
},

0 commit comments

Comments
 (0)