Skip to content

Commit d6d8163

Browse files
committed
chore: lint
1 parent 658ef19 commit d6d8163

3 files changed

Lines changed: 27 additions & 16 deletions

File tree

application/tests/chat_completion_test.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ def test_completion_returns_503_json_on_gemini_429(self) -> None:
3737
},
3838
None,
3939
)
40-
with patch(
41-
"application.prompt_client.prompt_client.PromptHandler"
42-
) as mock_ph:
40+
with patch("application.prompt_client.prompt_client.PromptHandler") as mock_ph:
4341
mock_ph.return_value.generate_text.side_effect = err
4442
with self.app.test_client() as client:
4543
response = client.post(
@@ -56,12 +54,16 @@ def test_completion_propagates_non_429_genai_error(self) -> None:
5654
os.environ["NO_LOGIN"] = "1"
5755
err = genai_errors.ClientError(
5856
400,
59-
{"error": {"code": 400, "message": "Bad request", "status": "INVALID_ARGUMENT"}},
57+
{
58+
"error": {
59+
"code": 400,
60+
"message": "Bad request",
61+
"status": "INVALID_ARGUMENT",
62+
}
63+
},
6064
None,
6165
)
62-
with patch(
63-
"application.prompt_client.prompt_client.PromptHandler"
64-
) as mock_ph:
66+
with patch("application.prompt_client.prompt_client.PromptHandler") as mock_ph:
6567
mock_ph.return_value.generate_text.side_effect = err
6668
with self.app.test_client() as client:
6769
with self.assertRaises(genai_errors.ClientError) as ctx:

application/tests/vertex_prompt_client_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ def test_is_genai_rate_limit_error_recognizes_clienterror_code_429(self) -> None
7272
def test_is_genai_rate_limit_error_false_for_other_clienterror(self) -> None:
7373
err = genai_errors.ClientError(
7474
400,
75-
{"error": {"code": 400, "message": "Bad request", "status": "INVALID_ARGUMENT"}},
75+
{
76+
"error": {
77+
"code": 400,
78+
"message": "Bad request",
79+
"status": "INVALID_ARGUMENT",
80+
}
81+
},
7682
None,
7783
)
7884
self.assertFalse(_is_genai_rate_limit_error(err))

application/web/web_main.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -927,14 +927,17 @@ def chat_cre() -> Any:
927927
except genai_errors.ClientError as e:
928928
# google.genai APIError uses ``code`` (HTTP status), not ``status_code``.
929929
if getattr(e, "code", None) == 429:
930-
return jsonify(
931-
{
932-
"error": (
933-
"The AI service is temporarily rate-limited. "
934-
"Please try again in a minute."
935-
)
936-
}
937-
), 503
930+
return (
931+
jsonify(
932+
{
933+
"error": (
934+
"The AI service is temporarily rate-limited. "
935+
"Please try again in a minute."
936+
)
937+
}
938+
),
939+
503,
940+
)
938941
raise
939942
return jsonify(response)
940943

0 commit comments

Comments
 (0)