Skip to content

Commit ca26b7c

Browse files
committed
fixes non test linting and formatting
1 parent a4dc546 commit ca26b7c

File tree

13 files changed

+53
-51
lines changed

13 files changed

+53
-51
lines changed

supertokens_python/framework/django/django_middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def __asyncMiddleware(request: HttpRequest):
4949
request.supertokens, SessionContainer # type: ignore
5050
):
5151
manage_session_post_response(
52-
request.supertokens, result, user_context # type: ignore
52+
request.supertokens, result, user_context # type: ignore
5353
)
5454
if isinstance(result, DjangoResponse):
5555
return result.response
@@ -85,7 +85,7 @@ def __syncMiddleware(request: HttpRequest):
8585
request.supertokens, SessionContainer # type: ignore
8686
):
8787
manage_session_post_response(
88-
request.supertokens, result, user_context # type: ignore
88+
request.supertokens, result, user_context # type: ignore
8989
)
9090
return result.response
9191

supertokens_python/framework/fastapi/fastapi_middleware.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint):
5959
if hasattr(request.state, "supertokens") and isinstance(
6060
request.state.supertokens, SessionContainer
6161
):
62-
manage_session_post_response(request.state.supertokens, result, user_context)
62+
manage_session_post_response(
63+
request.state.supertokens, result, user_context
64+
)
6365
if isinstance(result, FastApiResponse):
6466
return result.response
6567
except SuperTokensError as e:

supertokens_python/recipe/dashboard/api/analytics.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ async def handle_analytics_post(
6161
None,
6262
_user_context,
6363
)
64-
if (
65-
"exists" in response
66-
and response["exists"]
67-
and "telemetryId" in response
68-
):
64+
if "exists" in response and response["exists"] and "telemetryId" in response:
6965
telemetry_id = response["telemetryId"]
7066

7167
number_of_users = await Supertokens.get_instance().get_user_count(

supertokens_python/recipe/passwordless/recipe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from __future__ import annotations
1515

1616
from os import environ
17-
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, List, Union
17+
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, List, Union, Optional
1818

1919
from supertokens_python.ingredients.emaildelivery import EmailDeliveryIngredient
2020
from supertokens_python.ingredients.emaildelivery.types import EmailDeliveryConfig
@@ -24,7 +24,7 @@
2424
PasswordlessIngredients,
2525
PasswordlessLoginSMSTemplateVars,
2626
)
27-
from typing_extensions import Literal, Optional
27+
from typing_extensions import Literal
2828

2929
from .api import (
3030
consume_code,

supertokens_python/recipe/session/cookie_and_header.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,7 @@ def set_cookie_response_mutator(
142142
path_type: Literal["refresh_token_path", "access_token_path"],
143143
request: BaseRequest,
144144
):
145-
def mutator(
146-
response: BaseResponse,
147-
user_context: Dict[str, Any],
148-
):
145+
def mutator(response: BaseResponse, user_context: Dict[str, Any]):
149146
return _set_cookie(
150147
response, config, key, value, expires, path_type, request, user_context
151148
)
@@ -315,7 +312,10 @@ def token_response_mutator(
315312
transfer_method: TokenTransferMethod,
316313
request: BaseRequest,
317314
):
318-
def mutator(response: BaseResponse, user_context: Dict[str, Any],):
315+
def mutator(
316+
response: BaseResponse,
317+
user_context: Dict[str, Any],
318+
):
319319
_set_token(
320320
response,
321321
config,
@@ -343,7 +343,8 @@ def access_token_mutator(
343343
request: BaseRequest,
344344
):
345345
def mutator(
346-
response: BaseResponse, user_context: Dict[str, Any],
346+
response: BaseResponse,
347+
user_context: Dict[str, Any],
347348
):
348349
_set_access_token_in_response(
349350
response,

supertokens_python/recipe/session/framework/fastapi/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
from fastapi.responses import JSONResponse
2525

2626
from ...interfaces import SessionContainer, SessionClaimValidator
27-
from supertokens_python.utils import set_request_in_user_context_if_not_defined, default_user_context
27+
from supertokens_python.utils import (
28+
set_request_in_user_context_if_not_defined,
29+
default_user_context,
30+
)
2831

2932
from fastapi import Request
3033

supertokens_python/recipe/session/recipe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ async def handle_error(
232232
and err.response_mutators is not None
233233
):
234234
for mutator in err.response_mutators:
235-
mutator(response)
235+
mutator(response, user_context)
236236

237237
if isinstance(err, UnauthorisedError):
238238
log_debug_message("errorHandler: returning UNAUTHORISED")
@@ -246,7 +246,9 @@ async def handle_error(
246246
)
247247
if isinstance(err, TokenTheftError):
248248
log_debug_message("errorHandler: returning TOKEN_THEFT_DETECTED")
249-
log_debug_message("Clearing tokens because of TOKEN_THEFT_DETECTED response")
249+
log_debug_message(
250+
"Clearing tokens because of TOKEN_THEFT_DETECTED response"
251+
)
250252
clear_session_from_all_token_transfer_methods(
251253
response, self, request, user_context
252254
)

supertokens_python/recipe/session/recipe_implementation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ async def get_session(
182182
user_context: Optional[Dict[str, Any]] = None,
183183
) -> Optional[SessionContainer]:
184184
if (
185-
anti_csrf_check is not False and
186-
isinstance(self.config.anti_csrf_function_or_string, str) and
187-
self.config.anti_csrf_function_or_string == "VIA_CUSTOM_HEADER"
185+
anti_csrf_check is not False
186+
and isinstance(self.config.anti_csrf_function_or_string, str)
187+
and self.config.anti_csrf_function_or_string == "VIA_CUSTOM_HEADER"
188188
):
189189
raise Exception(
190190
"Since the anti-csrf mode is VIA_CUSTOM_HEADER getSession can't check the CSRF token. Please either use VIA_TOKEN or set anti_csrf_check to false"

supertokens_python/recipe/session/session_class.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@
3636
)
3737
from .constants import protected_props
3838
from ...framework import BaseRequest
39-
from supertokens_python.utils import (
40-
log_debug_message,
41-
default_user_context
42-
)
39+
from supertokens_python.utils import log_debug_message, default_user_context
4340

4441
_T = TypeVar("_T")
4542

@@ -327,7 +324,7 @@ async def merge_into_access_token_payload(
327324
self.front_token,
328325
self.config,
329326
transfer_method,
330-
self.req_res_info.request
327+
self.req_res_info.request,
331328
)
332329
)
333330
else:

supertokens_python/recipe/session/session_functions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ async def get_session(
244244
)
245245
raise_try_refresh_token_exception("anti-csrf check failed")
246246

247-
elif (isinstance(config.anti_csrf_function_or_string, str) and config.anti_csrf_function_or_string == "VIA_CUSTOM_HEADER"):
247+
elif (
248+
isinstance(config.anti_csrf_function_or_string, str)
249+
and config.anti_csrf_function_or_string == "VIA_CUSTOM_HEADER"
250+
):
248251
# The function should never be called by this (we check this outside the function as well)
249252
# There we can add a bit more information to the error, so that's the primary check, this is just making sure.
250253
raise Exception(
@@ -342,7 +345,9 @@ async def refresh_session(
342345
data["antiCsrfToken"] = anti_csrf_token
343346

344347
if (
345-
isinstance(recipe_implementation.config.anti_csrf_function_or_string, str) and recipe_implementation.config.anti_csrf_function_or_string == "VIA_CUSTOM_HEADER"
348+
isinstance(recipe_implementation.config.anti_csrf_function_or_string, str)
349+
and recipe_implementation.config.anti_csrf_function_or_string
350+
== "VIA_CUSTOM_HEADER"
346351
and not disable_anti_csrf
347352
):
348353
# The function should never be called by this (we check this outside the function as well)

0 commit comments

Comments
 (0)