Skip to content

Commit e8db345

Browse files
committed
Address review: narrow user_id and auth header types, ClassVar codenames
1 parent c466fa5 commit e8db345

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

config/admin_auth/backends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def authenticate(
8787
logger.warning("Auth0 admin auth failed: user %s not found", auth0_user_id)
8888
return None
8989

90-
def get_user(self, user_id: Any) -> Optional["User"]:
90+
def get_user(self, user_id: int) -> Optional["User"]:
9191
"""Retrieve user by primary key."""
9292
try:
9393
return UserModel.objects.get(pk=user_id)

config/graphql_api_token_auth/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_authorization_header(request: HttpRequest) -> bytes:
1818
coerce it to ``bytes`` here so downstream callers can treat the
1919
header uniformly (``.split()`` on ``bytes`` returns ``list[bytes]``).
2020
"""
21-
auth: Any = request.META.get("HTTP_AUTHORIZATION", b"")
21+
auth: str | bytes = request.META.get("HTTP_AUTHORIZATION", b"")
2222
if isinstance(auth, str):
2323
# Work around django test client oddness
2424
auth = auth.encode(HTTP_HEADER_ENCODING)

opencontractserver/users/query_optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Provides optimized user queries with profile privacy filtering and corpus membership visibility.
55
"""
66

7-
from typing import TYPE_CHECKING, Optional, Union
7+
from typing import TYPE_CHECKING, ClassVar, Optional, Union
88

99
from django.contrib.auth.models import AnonymousUser
1010
from django.db.models import Q, QuerySet
@@ -39,7 +39,7 @@ class UserQueryOptimizer:
3939
"""
4040

4141
# Permission codenames that indicate > READ access
42-
WRITE_PERMISSION_CODENAMES: list[str] = [
42+
WRITE_PERMISSION_CODENAMES: ClassVar[list[str]] = [
4343
"create_corpus",
4444
"update_corpus",
4545
"remove_corpus",

0 commit comments

Comments
 (0)