Skip to content

Commit 62438f8

Browse files
committed
Add return code for TokenExpired
1 parent fa95d7d commit 62438f8

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

api/authentication.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import shlex
55
from datetime import UTC, datetime
66
from hashlib import sha256
7-
from typing import Any, Literal, NoReturn, NotRequired, TypedDict, assert_never, cast
7+
from typing import Any, Literal, NoReturn, NotRequired, TypedDict, cast
88

99
from django.conf import settings
1010
from django.contrib.auth.models import AnonymousUser, User
@@ -249,6 +249,7 @@ def __eq__(self, other: Any) -> bool:
249249
"NotJsonDict",
250250
"NotOK",
251251
"NoSubject",
252+
"TokenExpired",
252253
}
253254

254255
_exception_code: dict[INTROSPECT_ERROR, Literal[401, 503]] = {
@@ -260,6 +261,7 @@ def __eq__(self, other: Any) -> bool:
260261
"NotAuthorized": 401,
261262
"NotActive": 401,
262263
"NoSubject": 503,
264+
"TokenExpired": 401,
263265
}
264266

265267
def raise_exception(self, method: str, path: str) -> NoReturn:
@@ -281,7 +283,6 @@ def raise_exception(self, method: str, path: str) -> NoReturn:
281283
raise IntrospectAuthenticationFailed(self)
282284
elif code == 503:
283285
raise IntrospectUnavailable(self)
284-
assert_never(code)
285286

286287
def as_cache_value(self) -> CachedFxaIntrospectResponse:
287288
cached: CachedFxaIntrospectResponse = {"error": self.error}

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ exclude_also = [
1515
"if TYPE_CHECKING:",
1616
# Skip abstract methods
1717
"raise NotImplementedError",
18-
# Skip mypy exhaustion statement
19-
"assert_never\\(.*\\)",
2018
]
2119

2220
[tool.coverage.run]

0 commit comments

Comments
 (0)