Skip to content

Commit 74ccbcc

Browse files
committed
fix: Operator precedence in flashlight tags retry
Also correct variable in error
1 parent c6768d3 commit 74ccbcc

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
@@ -61,7 +61,9 @@ def _make_tags_request(
6161
"invalid urchin API key"
6262
)
6363

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

134-
cheating_severity = validate_tag_severity(tags_data.get("cheating", None))
136+
raw_cheating_severity = tags_data.get("cheating", None)
137+
cheating_severity = validate_tag_severity(raw_cheating_severity)
135138
if cheating_severity is None:
136-
raise APIError(
137-
f"Invalid cheating tag severity " f"{response_json.get('cheating', None)=}"
138-
)
139-
sniper_severity = validate_tag_severity(tags_data.get("sniping", None))
139+
raise APIError(f"Invalid cheating tag severity " f"{raw_cheating_severity=}")
140+
141+
raw_sniper_severity = tags_data.get("sniping", None)
142+
sniper_severity = validate_tag_severity(raw_sniper_severity)
140143
if sniper_severity is None:
141-
raise APIError(
142-
f"Invalid sniping tag severity " f"{response_json.get('sniping', None)=}"
143-
)
144+
raise APIError(f"Invalid sniping tag severity " f"{raw_sniper_severity=}")
144145

145146
return Tags(
146147
cheating=cheating_severity,

0 commit comments

Comments
 (0)