Skip to content

Commit 7b2262f

Browse files
committed
fix: Operator precedence in flashlight tags retry
Also correct variable in error
1 parent 286834c commit 7b2262f

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/prism/flashlight.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def _make_tags_request(
6060
"invalid urchin API key"
6161
)
6262

63-
if response.status_code == 429 or response.status_code == 503 and not last_try:
63+
if (
64+
response.status_code == 429 or response.status_code == 503
65+
) and not last_try:
6466
raise ExecutionError(
6567
"Request to flashlight failed due to intermittent error, retrying"
6668
)
@@ -133,16 +135,15 @@ def parse_flashlight_tags(response_json: object) -> Tags:
133135
if not isinstance(tags_data, dict):
134136
raise APIError(f"Invalid tags data {tags_data=} {type(tags_data)=}")
135137

136-
cheating_severity = validate_tag_severity(tags_data.get("cheating", None))
138+
raw_cheating_severity = tags_data.get("cheating", None)
139+
cheating_severity = validate_tag_severity(raw_cheating_severity)
137140
if cheating_severity is None:
138-
raise APIError(
139-
f"Invalid cheating tag severity " f"{response_json.get('cheating', None)=}"
140-
)
141-
sniper_severity = validate_tag_severity(tags_data.get("sniping", None))
141+
raise APIError(f"Invalid cheating tag severity " f"{raw_cheating_severity=}")
142+
143+
raw_sniper_severity = tags_data.get("sniping", None)
144+
sniper_severity = validate_tag_severity(raw_sniper_severity)
142145
if sniper_severity is None:
143-
raise APIError(
144-
f"Invalid sniping tag severity " f"{response_json.get('sniping', None)=}"
145-
)
146+
raise APIError(f"Invalid sniping tag severity " f"{raw_sniper_severity=}")
146147

147148
return Tags(
148149
cheating=cheating_severity,

0 commit comments

Comments
 (0)