Skip to content

Commit f2482c3

Browse files
Apply Ruff formatting for CI compliance
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent d533154 commit f2482c3

File tree

9 files changed

+41
-24
lines changed

9 files changed

+41
-24
lines changed

hyperbrowser/client/file_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ def ensure_existing_file_path(
2727
if not not_file_message.strip():
2828
raise HyperbrowserError("not_file_message must not be empty")
2929
if any(
30-
ord(character) < 32 or ord(character) == 127
31-
for character in not_file_message
30+
ord(character) < 32 or ord(character) == 127 for character in not_file_message
3231
):
3332
raise HyperbrowserError("not_file_message must not contain control characters")
3433
try:

hyperbrowser/client/managers/response_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def parse_response_model(
5151
if isinstance(key, str):
5252
continue
5353
raise HyperbrowserError(
54-
"Expected "
55-
f"{normalized_operation_name} response object keys to be strings"
54+
f"Expected {normalized_operation_name} response object keys to be strings"
5655
)
5756
try:
5857
return model(**response_payload)

hyperbrowser/client/managers/session_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def parse_session_response_model(
2121
)
2222

2323

24-
def parse_session_recordings_response_data(response_data: Any) -> List[SessionRecording]:
24+
def parse_session_recordings_response_data(
25+
response_data: Any,
26+
) -> List[SessionRecording]:
2527
if not isinstance(response_data, list):
2628
raise HyperbrowserError(
2729
"Expected session recording response to be a list of objects"

hyperbrowser/client/polling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def _safe_exception_text(exc: Exception) -> str:
4444
if sanitized_exception_message.strip():
4545
if len(sanitized_exception_message) <= _MAX_EXCEPTION_TEXT_LENGTH:
4646
return sanitized_exception_message
47-
available_message_length = (
48-
_MAX_EXCEPTION_TEXT_LENGTH - len(_TRUNCATED_EXCEPTION_TEXT_SUFFIX)
47+
available_message_length = _MAX_EXCEPTION_TEXT_LENGTH - len(
48+
_TRUNCATED_EXCEPTION_TEXT_SUFFIX
4949
)
5050
if available_message_length <= 0:
5151
return _TRUNCATED_EXCEPTION_TEXT_SUFFIX

tests/test_extension_utils.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def test_parse_extension_list_response_data_rejects_non_dict_payload():
3535

3636
def test_parse_extension_list_response_data_rejects_missing_extensions_key():
3737
with pytest.raises(
38-
HyperbrowserError, match="Expected 'extensions' key in response but got \\[\\] keys"
38+
HyperbrowserError,
39+
match="Expected 'extensions' key in response but got \\[\\] keys",
3940
):
4041
parse_extension_list_response_data({})
4142

@@ -263,9 +264,7 @@ def __getitem__(self, key: str) -> object:
263264
with pytest.raises(
264265
HyperbrowserError, match="Failed to read extension object at index 0"
265266
) as exc_info:
266-
parse_extension_list_response_data(
267-
{"extensions": [_BrokenExtensionMapping()]}
268-
)
267+
parse_extension_list_response_data({"extensions": [_BrokenExtensionMapping()]})
269268

270269
assert exc_info.value.original_error is not None
271270

@@ -285,8 +284,6 @@ def __getitem__(self, key: str) -> object:
285284
with pytest.raises(
286285
HyperbrowserError, match="custom extension read failure"
287286
) as exc_info:
288-
parse_extension_list_response_data(
289-
{"extensions": [_BrokenExtensionMapping()]}
290-
)
287+
parse_extension_list_response_data({"extensions": [_BrokenExtensionMapping()]})
291288

292289
assert exc_info.value.original_error is None

tests/test_file_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def test_ensure_existing_file_path_rejects_non_string_missing_message(tmp_path:
2424
file_path = tmp_path / "file.txt"
2525
file_path.write_text("content")
2626

27-
with pytest.raises(HyperbrowserError, match="missing_file_message must be a string"):
27+
with pytest.raises(
28+
HyperbrowserError, match="missing_file_message must be a string"
29+
):
2830
ensure_existing_file_path(
2931
str(file_path),
3032
missing_file_message=123, # type: ignore[arg-type]

tests/test_response_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ def post(self, url, data=None, files=None):
336336
return _FakeResponse(["invalid"])
337337

338338
manager = SyncComputerActionManager(_FakeClient(_SyncTransport()))
339-
session = SimpleNamespace(computer_action_endpoint="https://example.com/computer-action")
339+
session = SimpleNamespace(
340+
computer_action_endpoint="https://example.com/computer-action"
341+
)
340342

341343
with pytest.raises(
342344
HyperbrowserError, match="Expected computer action response to be an object"
@@ -353,7 +355,9 @@ async def post(self, url, data=None, files=None):
353355
return _FakeResponse(["invalid"])
354356

355357
manager = AsyncComputerActionManager(_FakeClient(_AsyncTransport()))
356-
session = SimpleNamespace(computer_action_endpoint="https://example.com/computer-action")
358+
session = SimpleNamespace(
359+
computer_action_endpoint="https://example.com/computer-action"
360+
)
357361

358362
async def run() -> None:
359363
with pytest.raises(

tests/test_transport_base.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ def test_api_response_from_json_sanitizes_and_truncates_model_name_in_errors() -
206206
)
207207

208208

209-
def test_api_response_from_json_uses_placeholder_for_blank_mapping_key_in_errors() -> None:
209+
def test_api_response_from_json_uses_placeholder_for_blank_mapping_key_in_errors() -> (
210+
None
211+
):
210212
with pytest.raises(
211213
HyperbrowserError,
212214
match=(
@@ -217,7 +219,9 @@ def test_api_response_from_json_uses_placeholder_for_blank_mapping_key_in_errors
217219
APIResponse.from_json(_BrokenBlankKeyValueMapping(), _SampleResponseModel)
218220

219221

220-
def test_api_response_from_json_sanitizes_and_truncates_mapping_keys_in_errors() -> None:
222+
def test_api_response_from_json_sanitizes_and_truncates_mapping_keys_in_errors() -> (
223+
None
224+
):
221225
with pytest.raises(
222226
HyperbrowserError,
223227
match=(
@@ -249,7 +253,9 @@ def test_api_response_constructor_rejects_boolean_status_code() -> None:
249253
def test_api_response_constructor_rejects_out_of_range_status_code(
250254
status_code: int,
251255
) -> None:
252-
with pytest.raises(HyperbrowserError, match="status_code must be between 100 and 599"):
256+
with pytest.raises(
257+
HyperbrowserError, match="status_code must be between 100 and 599"
258+
):
253259
APIResponse(status_code=status_code)
254260

255261

@@ -262,5 +268,7 @@ def test_api_response_from_status_rejects_boolean_status_code() -> None:
262268
def test_api_response_from_status_rejects_out_of_range_status_code(
263269
status_code: int,
264270
) -> None:
265-
with pytest.raises(HyperbrowserError, match="status_code must be between 100 and 599"):
271+
with pytest.raises(
272+
HyperbrowserError, match="status_code must be between 100 and 599"
273+
):
266274
APIResponse.from_status(status_code)

tests/test_transport_error_utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ def test_format_request_failure_message_normalizes_sentinel_fallback_methods(
385385
assert message == "Request UNKNOWN https://example.com/fallback failed"
386386

387387

388-
@pytest.mark.parametrize("numeric_like_method", ["1", "1.5", "-1.25", "+2", ".75", "1e3"])
388+
@pytest.mark.parametrize(
389+
"numeric_like_method", ["1", "1.5", "-1.25", "+2", ".75", "1e3"]
390+
)
389391
def test_format_request_failure_message_normalizes_numeric_like_fallback_methods(
390392
numeric_like_method: str,
391393
):
@@ -625,7 +627,9 @@ def test_format_generic_request_failure_message_normalizes_sentinel_method_value
625627
assert message == "Request UNKNOWN https://example.com/path failed"
626628

627629

628-
@pytest.mark.parametrize("numeric_like_method", ["1", "1.5", "-1.25", "+2", ".75", "1e3"])
630+
@pytest.mark.parametrize(
631+
"numeric_like_method", ["1", "1.5", "-1.25", "+2", ".75", "1e3"]
632+
)
629633
def test_format_generic_request_failure_message_normalizes_numeric_like_method_values(
630634
numeric_like_method: str,
631635
):
@@ -782,7 +786,9 @@ def test_extract_error_message_handles_broken_fallback_response_text():
782786

783787

784788
def test_extract_error_message_uses_placeholder_for_blank_fallback_error_text():
785-
message = extract_error_message(_DummyResponse(" ", text=" "), _BlankFallbackError())
789+
message = extract_error_message(
790+
_DummyResponse(" ", text=" "), _BlankFallbackError()
791+
)
786792

787793
assert message == "<_BlankFallbackError>"
788794

0 commit comments

Comments
 (0)