Skip to content

Commit b4c6203

Browse files
committed
W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
1 parent 9f02235 commit b4c6203

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

00-Starter-Seed/server.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ def decorated(*args, **kwargs):
8989
jwks = json.loads(jsonurl.read())
9090
try:
9191
unverified_header = jwt.get_unverified_header(token)
92-
except jwt.JWTError:
92+
except jwt.JWTError as jwt_error:
9393
raise AuthError({"code": "invalid_header",
9494
"description":
9595
"Invalid header. "
96-
"Use an RS256 signed JWT Access Token"}, 401)
96+
"Use an RS256 signed JWT Access Token"}, 401) from jwt_error
9797
if unverified_header["alg"] == "HS256":
9898
raise AuthError({"code": "invalid_header",
9999
"description":
@@ -118,19 +118,19 @@ def decorated(*args, **kwargs):
118118
audience=API_IDENTIFIER,
119119
issuer="https://"+AUTH0_DOMAIN+"/"
120120
)
121-
except jwt.ExpiredSignatureError:
121+
except jwt.ExpiredSignatureError as expired_sign_error:
122122
raise AuthError({"code": "token_expired",
123-
"description": "token is expired"}, 401)
124-
except jwt.JWTClaimsError:
123+
"description": "token is expired"}, 401) from expired_sign_error
124+
except jwt.JWTClaimsError as jwt_claims_error:
125125
raise AuthError({"code": "invalid_claims",
126126
"description":
127127
"incorrect claims,"
128-
" please check the audience and issuer"}, 401)
129-
except Exception:
128+
" please check the audience and issuer"}, 401) from jwt_claims_error
129+
except Exception as exc:
130130
raise AuthError({"code": "invalid_header",
131131
"description":
132132
"Unable to parse authentication"
133-
" token."}, 401)
133+
" token."}, 401) from exc
134134

135135
_request_ctx_stack.top.current_user = payload
136136
return func(*args, **kwargs)

0 commit comments

Comments
 (0)