Skip to content

Commit 5bee7e5

Browse files
committed
lint: more ruff
1 parent c6b4b96 commit 5bee7e5

File tree

26 files changed

+129
-162
lines changed

26 files changed

+129
-162
lines changed

supertokens_python/framework/django/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414
from supertokens_python.framework.django.django_middleware import (
15-
middleware, # type: ignore
15+
middleware as middleware,
1616
)

supertokens_python/recipe/emailpassword/api/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
from .email_exists import handle_email_exists_api # type: ignore
14+
from .email_exists import handle_email_exists_api as handle_email_exists_api
1515
from .generate_password_reset_token import (
16-
handle_generate_password_reset_token_api, # type: ignore
16+
handle_generate_password_reset_token_api as handle_generate_password_reset_token_api,
1717
)
18-
from .password_reset import handle_password_reset_api # type: ignore
19-
from .signin import handle_sign_in_api # type: ignore
20-
from .signup import handle_sign_up_api # type: ignore
18+
from .password_reset import handle_password_reset_api as handle_password_reset_api
19+
from .signin import handle_sign_in_api as handle_sign_in_api
20+
from .signup import handle_sign_up_api as handle_sign_up_api

supertokens_python/recipe/emailverification/api/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
from .email_verify import handle_email_verify_api # type: ignore
14+
from .email_verify import handle_email_verify_api as handle_email_verify_api
1515
from .generate_email_verify_token import (
16-
handle_generate_email_verify_token_api, # type: ignore
16+
handle_generate_email_verify_token_api as handle_generate_email_verify_token_api,
1717
)

supertokens_python/recipe/multitenancy/api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
from .login_methods import handle_login_methods_api # type: ignore
14+
from .login_methods import handle_login_methods_api as handle_login_methods_api

supertokens_python/recipe/oauth2provider/api/__init__.py

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

15-
from .auth import auth_get # type: ignore
16-
from .end_session import end_session_get, end_session_post # type: ignore
17-
from .introspect_token import introspect_token_post # type: ignore
18-
from .login import login # type: ignore
19-
from .login_info import login_info_get # type: ignore
20-
from .logout import logout_post # type: ignore
21-
from .revoke_token import revoke_token_post # type: ignore
22-
from .token import token_post # type: ignore
23-
from .user_info import user_info_get # type: ignore
15+
from .auth import auth_get as auth_get
16+
from .end_session import end_session_get as end_session_get
17+
from .end_session import end_session_post as end_session_post
18+
from .introspect_token import introspect_token_post as introspect_token_post
19+
from .login import login as login
20+
from .login_info import login_info_get as login_info_get
21+
from .logout import logout_post as logout_post
22+
from .revoke_token import revoke_token_post as revoke_token_post
23+
from .token import token_post as token_post
24+
from .user_info import user_info_get as user_info_get

supertokens_python/recipe/passwordless/api/__init__.py

Lines changed: 5 additions & 5 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 .consume_code import consume_code # type: ignore
16-
from .create_code import create_code # type: ignore
17-
from .email_exists import email_exists # type: ignore
18-
from .phone_number_exists import phone_number_exists # type: ignore
19-
from .resend_code import resend_code # type: ignore
15+
from .consume_code import consume_code as consume_code
16+
from .create_code import create_code as create_code
17+
from .email_exists import email_exists as email_exists
18+
from .phone_number_exists import phone_number_exists as phone_number_exists
19+
from .resend_code import resend_code as resend_code

supertokens_python/recipe/session/access_token.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from supertokens_python.logger import log_debug_message
2222
from supertokens_python.recipe.multitenancy.constants import DEFAULT_TENANT_ID
23+
from supertokens_python.recipe.session.jwks import get_latest_keys
2324
from supertokens_python.recipe.session.utils import SessionConfig
2425
from supertokens_python.utils import get_timestamp_ms
2526

@@ -44,9 +45,6 @@ def sanitize_number(n: Any) -> Union[Union[int, float], None]:
4445
return None
4546

4647

47-
from supertokens_python.recipe.session.jwks import get_latest_keys
48-
49-
5048
def get_info_from_access_token(
5149
config: SessionConfig,
5250
jwt_info: ParsedJWTInfo,

supertokens_python/recipe/session/api/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
from .refresh import handle_refresh_api # type: ignore
15-
from .signout import handle_signout_api # type: ignore
14+
from .refresh import handle_refresh_api as handle_refresh_api
15+
from .signout import handle_signout_api as handle_signout_api

supertokens_python/recipe/thirdparty/providers/gitlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
ProviderConfigForClient,
2424
)
2525

26-
from ..provider import Provider, ProviderInput
26+
from ..provider import ProviderInput
2727
from .custom import GenericProvider, NewProvider
2828
from .utils import normalise_oidc_endpoint_to_include_well_known
2929

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
)
7878
from supertokens_python.recipe.thirdparty.interfaces import APIOptions as TPAPIOptions
7979
from supertokens_python.recipe.thirdparty.provider import Provider, RedirectUriInfo
80+
from supertokens_python.recipe.thirdparty.types import UserInfo, UserInfoEmail
8081
from supertokens_python.recipe.totp.recipe import TOTPRecipe
8182
from supertokens_python.recipe.userroles import UserRolesRecipe
8283
from supertokens_python.types import GeneralErrorResponse, User
@@ -200,9 +201,6 @@ async def check_for_general_error(
200201
return is_general_error
201202

202203

203-
from supertokens_python.recipe.thirdparty.types import UserInfo, UserInfoEmail
204-
205-
206204
def auth0_provider_override(oi: Provider) -> Provider:
207205
async def get_user_info(
208206
oauth_tokens: Dict[str, Any],

tests/auth-react/django3x/polls/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,11 @@ async def setup_tenant(request: HttpRequest):
311311
core_config = body.get("coreConfig", {})
312312

313313
first_factors: List[str] = []
314-
if login_methods.get("emailPassword", {}).get("enabled") == True:
314+
if login_methods.get("emailPassword", {}).get("enabled") is True:
315315
first_factors.append("emailpassword")
316-
if login_methods.get("thirdParty", {}).get("enabled") == True:
316+
if login_methods.get("thirdParty", {}).get("enabled") is True:
317317
first_factors.append("thirdparty")
318-
if login_methods.get("passwordless", {}).get("enabled") == True:
318+
if login_methods.get("passwordless", {}).get("enabled") is True:
319319
first_factors.extend(["otp-phone", "otp-email", "link-phone", "link-email"])
320320

321321
core_resp = await create_or_update_tenant(

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
SignInUpNotAllowed,
160160
)
161161
from supertokens_python.recipe.thirdparty.provider import Provider, RedirectUriInfo
162+
from supertokens_python.recipe.thirdparty.types import UserInfo, UserInfoEmail
162163
from supertokens_python.recipe.totp.recipe import TOTPRecipe
163164
from supertokens_python.recipe.userroles import (
164165
PermissionClaim,
@@ -338,8 +339,6 @@ async def validate_age(value: Any, tenant_id: str):
338339
InputFormField("country", optional=True),
339340
]
340341

341-
from supertokens_python.recipe.thirdparty.types import UserInfo, UserInfoEmail
342-
343342

344343
def auth0_provider_override(oi: Provider) -> Provider:
345344
async def get_user_info(
@@ -1236,11 +1235,11 @@ async def setup_tenant(request: Request):
12361235
core_config = body.get("coreConfig", {})
12371236

12381237
first_factors: List[str] = []
1239-
if login_methods.get("emailPassword", {}).get("enabled") == True:
1238+
if login_methods.get("emailPassword", {}).get("enabled") is True:
12401239
first_factors.append("emailpassword")
1241-
if login_methods.get("thirdParty", {}).get("enabled") == True:
1240+
if login_methods.get("thirdParty", {}).get("enabled") is True:
12421241
first_factors.append("thirdparty")
1243-
if login_methods.get("passwordless", {}).get("enabled") == True:
1242+
if login_methods.get("passwordless", {}).get("enabled") is True:
12441243
first_factors.extend(["otp-phone", "otp-email", "link-phone", "link-email"])
12451244

12461245
core_resp = await create_or_update_tenant(

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
RedirectUriInfo,
157157
)
158158
from supertokens_python.recipe.thirdparty.syncio import manually_create_or_update_user
159+
from supertokens_python.recipe.thirdparty.types import UserInfo, UserInfoEmail
159160
from supertokens_python.recipe.totp.recipe import TOTPRecipe
160161
from supertokens_python.recipe.userroles import (
161162
PermissionClaim,
@@ -319,9 +320,6 @@ async def check_for_general_error(
319320
return is_general_error
320321

321322

322-
from supertokens_python.recipe.thirdparty.types import UserInfo, UserInfoEmail
323-
324-
325323
def auth0_provider_override(oi: Provider) -> Provider:
326324
async def get_user_info(
327325
oauth_tokens: Dict[str, Any],
@@ -1212,11 +1210,11 @@ def setup_tenant():
12121210
core_config: Dict[str, Any] = "coreConfig" in body and body["coreConfig"] or {}
12131211

12141212
first_factors: List[str] = []
1215-
if login_methods.get("emailPassword", {}).get("enabled") == True:
1213+
if login_methods.get("emailPassword", {}).get("enabled") is True:
12161214
first_factors.append("emailpassword")
1217-
if login_methods.get("thirdParty", {}).get("enabled") == True:
1215+
if login_methods.get("thirdParty", {}).get("enabled") is True:
12181216
first_factors.append("thirdparty")
1219-
if login_methods.get("passwordless", {}).get("enabled") == True:
1217+
if login_methods.get("passwordless", {}).get("enabled") is True:
12201218
first_factors.extend(["otp-phone", "otp-email", "link-phone", "link-email"])
12211219

12221220
core_resp = create_or_update_tenant(

tests/emailverification/test_emailverification_claim.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_claim_value_should_be_fetched_if_it_is_None():
2121
validator = EmailVerificationClaim.validators.is_verified()
2222

2323
should_refetch_none = validator.should_refetch({}, {})
24-
assert should_refetch_none == True
24+
assert should_refetch_none is True
2525

2626

2727
def test_claim_value_should_be_fetched_as_per_max_age_if_provided():
@@ -35,7 +35,7 @@ def test_claim_value_should_be_fetched_as_per_max_age_if_provided():
3535
}
3636

3737
should_refetch_valid = validator.should_refetch(payload, {})
38-
assert should_refetch_valid == False
38+
assert should_refetch_valid is False
3939

4040
payload = {
4141
"st-ev": {
@@ -45,7 +45,7 @@ def test_claim_value_should_be_fetched_as_per_max_age_if_provided():
4545
}
4646

4747
should_refetch_expired = validator.should_refetch(payload, {})
48-
assert should_refetch_expired == True
48+
assert should_refetch_expired is True
4949

5050

5151
def test_claim_value_should_be_fetched_as_per_refetch_time_on_false_if_provided():
@@ -59,7 +59,7 @@ def test_claim_value_should_be_fetched_as_per_refetch_time_on_false_if_provided(
5959
}
6060

6161
should_refetch_valid = validator.should_refetch(payload, {})
62-
assert should_refetch_valid == False
62+
assert should_refetch_valid is False
6363

6464
payload = {
6565
"st-ev": {
@@ -69,7 +69,7 @@ def test_claim_value_should_be_fetched_as_per_refetch_time_on_false_if_provided(
6969
}
7070

7171
should_refetch_expired = validator.should_refetch(payload, {})
72-
assert should_refetch_expired == True
72+
assert should_refetch_expired is True
7373

7474

7575
def test_claim_value_should_be_fetched_as_per_default_refetch_time_on_false_if_not_provided():
@@ -84,7 +84,7 @@ def test_claim_value_should_be_fetched_as_per_default_refetch_time_on_false_if_n
8484
}
8585

8686
should_refetch_valid = validator.should_refetch(payload, {})
87-
assert should_refetch_valid == False
87+
assert should_refetch_valid is False
8888

8989
payload = {
9090
"st-ev": {
@@ -94,4 +94,4 @@ def test_claim_value_should_be_fetched_as_per_default_refetch_time_on_false_if_n
9494
}
9595

9696
should_refetch_expired = validator.should_refetch(payload, {})
97-
assert should_refetch_expired == True
97+
assert should_refetch_expired is True

tests/frontendIntegration/drf_async/mysite/settings.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
"""
1212

1313
import os
14-
from typing import List
14+
import sys
15+
from typing import Any, Dict, List, Union
1516

1617
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1718
from corsheaders.defaults import default_headers
19+
from supertokens_python import InputAppInfo, SupertokensConfig, init
20+
from supertokens_python.recipe import session
21+
from supertokens_python.recipe.session.interfaces import APIInterface, RecipeInterface
1822
from supertokens_python.types import RecipeUserId
1923

2024
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -148,13 +152,6 @@
148152

149153
STATIC_URL = "/static/"
150154

151-
import sys
152-
from typing import Any, Dict, Union
153-
154-
from supertokens_python import InputAppInfo, SupertokensConfig, init
155-
from supertokens_python.recipe import session
156-
from supertokens_python.recipe.session.interfaces import APIInterface, RecipeInterface
157-
158155

159156
def get_app_port():
160157
argvv = sys.argv

tests/frontendIntegration/drf_sync/mysite/settings.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
"""
1212

1313
import os
14-
from typing import List
14+
import sys
15+
from typing import Any, Dict, List, Union
1516

1617
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1718
from corsheaders.defaults import default_headers
19+
from supertokens_python import InputAppInfo, SupertokensConfig, init
20+
from supertokens_python.recipe import session
21+
from supertokens_python.recipe.session.interfaces import APIInterface, RecipeInterface
1822
from supertokens_python.types import RecipeUserId
1923

2024
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -148,13 +152,6 @@
148152

149153
STATIC_URL = "/static/"
150154

151-
import sys
152-
from typing import Any, Dict, Union
153-
154-
from supertokens_python import InputAppInfo, SupertokensConfig, init
155-
from supertokens_python.recipe import session
156-
from supertokens_python.recipe.session.interfaces import APIInterface, RecipeInterface
157-
158155

159156
def get_app_port():
160157
argvv = sys.argv

tests/frontendIntegration/fastapi-server/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from starlette.middleware.cors import CORSMiddleware
2525
from starlette.middleware.exceptions import ExceptionMiddleware
2626
from starlette.requests import Request
27+
from starlette.staticfiles import StaticFiles
2728
from supertokens_python import (
2829
InputAppInfo,
2930
Supertokens,
@@ -257,8 +258,6 @@ def send_file():
257258
return HTMLResponse(content=file_contents)
258259

259260

260-
from starlette.staticfiles import StaticFiles
261-
262261
app.mount("/angular", StaticFiles(directory="templates/angular"), name="angular")
263262
# aiofiles must be installed for this to work
264263

tests/frontendIntegration/flask-server/app.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@
1919
from functools import wraps
2020
from typing import Any, Dict, Union
2121

22-
from flask import Flask, g, jsonify, make_response, render_template, request
22+
from flask import (
23+
Flask,
24+
g,
25+
jsonify,
26+
make_response,
27+
render_template,
28+
request,
29+
send_from_directory, # type: ignore
30+
)
2331
from flask.wrappers import Response
2432
from flask_cors import CORS
2533
from supertokens_python import InputAppInfo, Supertokens, SupertokensConfig, init
@@ -279,9 +287,6 @@ def send_file():
279287
return render_template("index.html")
280288

281289

282-
from flask import send_from_directory # type: ignore
283-
284-
285290
@app.route("/angular/<path:path>", methods=["GET"]) # type: ignore
286291
def send_angular_file(path: str):
287292
return send_from_directory("templates/angular", path)

0 commit comments

Comments
 (0)