Skip to content

Commit 7144e45

Browse files
committed
Apply ruff format
1 parent d2f4bec commit 7144e45

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

jwt/api_jws.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ def encode(
171171
# base64-encoded.
172172
existing_crit = header.get("crit", [])
173173
if not isinstance(existing_crit, list):
174-
raise InvalidTokenError(
175-
"Invalid 'crit' header: must be a list"
176-
)
174+
raise InvalidTokenError("Invalid 'crit' header: must be a list")
177175
if "b64" not in existing_crit:
178176
header["crit"] = [*existing_crit, "b64"]
179177
elif "b64" in header:
@@ -259,8 +257,7 @@ def decode_complete(
259257
crit = header.get("crit") or []
260258
if not isinstance(crit, list) or "b64" not in crit:
261259
raise InvalidTokenError(
262-
"The 'b64' header parameter requires 'b64' to be "
263-
"listed in 'crit'."
260+
"The 'b64' header parameter requires 'b64' to be listed in 'crit'."
264261
)
265262
if detached_payload is None:
266263
raise DecodeError(
@@ -353,9 +350,7 @@ def _load(self, jwt: str | bytes) -> tuple[bytes, bytes, dict[str, Any], bytes]:
353350
# segment to force CPU + memory cost before the signature is
354351
# even checked.
355352
if payload_segment:
356-
raise DecodeError(
357-
"Payload segment must be empty when 'b64' is false."
358-
)
353+
raise DecodeError("Payload segment must be empty when 'b64' is false.")
359354
payload = b""
360355
else:
361356
try:

tests/test_api_jws.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,7 @@ def test_encode_b64_false_auto_adds_b64_to_crit(
989989
# RFC 7797 §3: producers MUST list "b64" in "crit" whenever "b64"
990990
# appears in the protected header.
991991
secret = "secret"
992-
token = jws.encode(
993-
payload, secret, algorithm="HS256", is_payload_detached=True
994-
)
992+
token = jws.encode(payload, secret, algorithm="HS256", is_payload_detached=True)
995993

996994
msg_header, _, _ = token.split(".")
997995
header_obj = json.loads(base64url_decode(msg_header.encode()))
@@ -1046,9 +1044,7 @@ def test_decode_b64_false_rejects_non_empty_payload_segment(
10461044
).decode()
10471045

10481046
with pytest.raises(DecodeError, match="Payload segment must be empty"):
1049-
jws.decode(
1050-
token, secret, algorithms=["HS256"], detached_payload=payload
1051-
)
1047+
jws.decode(token, secret, algorithms=["HS256"], detached_payload=payload)
10521048

10531049
def test_decode_b64_false_without_crit_b64_is_rejected(
10541050
self, jws: PyJWS, payload: bytes
@@ -1069,9 +1065,7 @@ def test_decode_b64_false_without_crit_b64_is_rejected(
10691065
token = b".".join([header_b64, b"", base64url_encode(sig)]).decode()
10701066

10711067
with pytest.raises(InvalidTokenError, match="b64.*crit"):
1072-
jws.decode(
1073-
token, secret, algorithms=["HS256"], detached_payload=payload
1074-
)
1068+
jws.decode(token, secret, algorithms=["HS256"], detached_payload=payload)
10751069

10761070
def test_decode_detached_content_without_proper_argument(
10771071
self, jws: PyJWS, payload: bytes

0 commit comments

Comments
 (0)