Skip to content

Commit 77456bd

Browse files
committed
fix: resolve linting errors in test files
- Add quotes to BinaryIO type expressions (TC006) - Fix line length error by splitting long assertion (E501) - Remove unused variable original_name (F841) All ruff checks now pass.
1 parent eca9aa8 commit 77456bd

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

tests/unit/test_direct_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ def test_direct_api_with_file_like_object(self, mock_process):
299299
temp_file.write(b"test content")
300300
temp_file.seek(0)
301301

302-
self.client.rotate_pages(cast(BinaryIO, temp_file), degrees=90)
303-
mock_process.assert_called_once_with("rotate-pages", cast(BinaryIO, temp_file), None, degrees=90)
302+
self.client.rotate_pages(cast("BinaryIO", temp_file), degrees=90)
303+
mock_process.assert_called_once_with(
304+
"rotate-pages", cast("BinaryIO", temp_file), None, degrees=90
305+
)
304306

305307

306308
class TestDirectAPIErrorHandling:

tests/unit/test_file_handler.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_prepare_file_input_from_file_handle(self):
7474
temp_file.write(content)
7575
temp_file.seek(0)
7676

77-
result, filename = prepare_file_input(cast(BinaryIO, temp_file))
77+
result, filename = prepare_file_input(cast("BinaryIO", temp_file))
7878
assert result == content
7979
assert filename == os.path.basename(temp_file.name)
8080

@@ -84,7 +84,7 @@ def test_prepare_file_input_from_string_file_handle(self):
8484
string_file = io.StringIO(string_content)
8585
string_file.name = "test.txt"
8686

87-
result, filename = prepare_file_input(cast(BinaryIO, string_file))
87+
result, filename = prepare_file_input(cast("BinaryIO", string_file))
8888
assert result == string_content.encode()
8989
assert filename == "test.txt"
9090

@@ -112,10 +112,9 @@ def test_prepare_file_input_file_handle_with_path_name(self):
112112
temp_file.seek(0)
113113

114114
# Mock the name to be a path-like object
115-
original_name = temp_file.name
116115
temp_file.name = Path(temp_file.name) # type: ignore
117116

118-
result, filename = prepare_file_input(cast(BinaryIO, temp_file))
117+
result, filename = prepare_file_input(cast("BinaryIO", temp_file))
119118
assert result == content
120119
assert filename == os.path.basename(str(temp_file.name))
121120

@@ -426,7 +425,7 @@ def test_get_file_size_seekable_file_object(self):
426425
temp_file.write(content)
427426
temp_file.seek(5) # Move to middle of file
428427

429-
size = get_file_size(cast(BinaryIO, temp_file))
428+
size = get_file_size(cast("BinaryIO", temp_file))
430429
assert size == len(content)
431430

432431
# Verify position was restored

0 commit comments

Comments
 (0)