Skip to content

Commit

Permalink
ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
liwen authored and cofin committed Aug 8, 2024
1 parent cd721c0 commit 07ec1cd
Show file tree
Hide file tree
Showing 2 changed files with 734 additions and 746 deletions.
10 changes: 3 additions & 7 deletions litestar/security/jwt/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ def decode(cls, encoded_token: str, secret: str | dict[str, str], algorithm: str
NotAuthorizedException: If the token is invalid.
"""
try:
payload = jwt.decode(jwt=encoded_token,
key=secret,
algorithms=[algorithm],
options={"verify_aud": False})
payload = jwt.decode(jwt=encoded_token, key=secret, algorithms=[algorithm], options={"verify_aud": False})
exp = datetime.fromtimestamp(payload.pop("exp"), tz=timezone.utc)
iat = datetime.fromtimestamp(payload.pop("iat"), tz=timezone.utc)
field_names = {f.name for f in dataclasses.fields(Token)}
Expand All @@ -117,8 +114,7 @@ def encode(self, secret: str, algorithm: str) -> str:
"""
try:
return jwt.encode(
payload={k: v for k, v in asdict(self).items() if v is not None},
key=secret,
algorithm=algorithm)
payload={k: v for k, v in asdict(self).items() if v is not None}, key=secret, algorithm=algorithm
)
except (PyJWTError, InvalidTokenError) as e:
raise ImproperlyConfiguredException("Failed to encode token") from e
Loading

0 comments on commit 07ec1cd

Please sign in to comment.