Skip to content

Commit 950198f

Browse files
lints
1 parent 010785b commit 950198f

6 files changed

Lines changed: 13 additions & 4 deletions

File tree

exceptions/http_exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __init__(self):
106106
class InvalidPermissionError(HTTPException):
107107
"""Raised when a user attempts to assign an invalid permission to a role"""
108108

109-
def __init__(self, permission: ValidPermissions):
109+
def __init__(self, permission: str):
110110
super().__init__(
111111
status_code=400,
112112
detail=f"Invalid permission: {permission}"

routers/core/account.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
InvitationEmailMismatchError,
5252
InvitationProcessingError
5353
)
54-
from utils.core.models import EmailVerificationToken
5554
from routers.core.dashboard import router as dashboard_router
5655
from routers.core.user import router as user_router
5756
from routers.core.organization import router as org_router
@@ -447,6 +446,7 @@ async def login(
447446
logger.info(f"Standard login for account {account.email}. Redirecting to dashboard.")
448447

449448
# Create access token
449+
assert account.id is not None
450450
access_token = create_access_token(
451451
data={"sub": account.email, "fresh": True}
452452
)
@@ -518,6 +518,7 @@ async def refresh_token(
518518
if not db_token or db_token.account_id != account.id:
519519
return RedirectResponse(url=router.url_path_for("read_login"), status_code=303)
520520

521+
assert account.id is not None
521522
if db_token.revoked:
522523
# Token reuse detected — revoke all tokens for this account
523524
logger.warning(
@@ -611,6 +612,7 @@ async def reset_password(
611612
if not authorized_account or not reset_token:
612613
raise CredentialsError("Invalid or expired password reset token; please request a new one")
613614

615+
assert authorized_account.id is not None
614616
# Update password and mark token as used
615617
authorized_account.hashed_password = get_password_hash(new_password)
616618

@@ -659,6 +661,7 @@ async def recover_account(
659661
if not account or not recovery_token:
660662
raise CredentialsError(message="Invalid or expired recovery token")
661663

664+
assert account.id is not None
662665
# Mark recovery token as used
663666
recovery_token.used = True
664667

@@ -733,6 +736,7 @@ async def add_email(
733736
if email_count >= MAX_EMAILS_PER_ACCOUNT:
734737
raise MaxEmailsReachedError()
735738

739+
assert account.id is not None
736740
# Send verification email (suppresses if unexpired token exists)
737741
sent = send_email_verification(account.id, new_email, session)
738742

@@ -760,6 +764,8 @@ async def verify_email(
760764
if not account or not verification_token:
761765
raise CredentialsError(message="Invalid or expired verification token")
762766

767+
assert account.id is not None
768+
763769
# Race condition guard: check email not already taken
764770
existing = session.exec(
765771
select(AccountEmail).where(AccountEmail.email == verification_token.new_email)
@@ -814,6 +820,7 @@ async def promote_email(
814820
"""
815821
Promote a secondary email address to primary.
816822
"""
823+
assert account.id is not None
817824
# Look up the AccountEmail
818825
target_email = session.exec(
819826
select(AccountEmail).where(
@@ -897,6 +904,7 @@ async def remove_email(
897904
"""
898905
Remove a non-primary email address from the account.
899906
"""
907+
assert account.id is not None
900908
target_email = session.exec(
901909
select(AccountEmail).where(
902910
AccountEmail.id == email_id,

tests/routers/core/test_account.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from main import app
1111
from utils.core.models import User, AccountEmail, AccountRecoveryToken, EmailVerificationToken, PasswordResetToken, RefreshToken, Account
12-
from tests.conftest import htmx_headers
1312
from utils.core.auth import (
1413
create_access_token,
1514
create_recovery_token,

utils/core/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from fastapi.templating import Jinja2Templates
1414
from fastapi import Cookie
1515
from utils.core.db import create_engine, get_connection_url
16-
from utils.core.models import AccountEmail, AccountRecoveryToken, EmailVerificationToken, PasswordResetToken, RefreshToken, Account
16+
from utils.core.models import AccountRecoveryToken, EmailVerificationToken, PasswordResetToken, RefreshToken, Account
1717

1818
logger = logging.getLogger(__name__)
1919
logger.setLevel(logging.DEBUG)

utils/core/db.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def seed_account_emails(session: Session) -> None:
217217
select(AccountEmail).where(AccountEmail.account_id == account.id)
218218
).first()
219219
if not existing:
220+
assert account.id is not None
220221
account_email = AccountEmail(
221222
account_id=account.id,
222223
email=account.email,

utils/core/dependencies.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def validate_token_and_get_account(
5858
)).first()
5959

6060
if account:
61+
assert account.id is not None
6162
if token_type == "refresh":
6263
jti = decoded_token.get("jti")
6364
if not jti:

0 commit comments

Comments
 (0)