style: apply ruff format to OCR modules

This commit is contained in:
2026-07-22 01:43:55 -04:00
parent 18d4f60665
commit fdd36e0e1f
5 changed files with 43 additions and 20 deletions
+16 -5
View File
@@ -249,14 +249,20 @@ class TestMiddleJsonDefense:
self._expect_invalid(_zip_bytes(_middle_bytes([page])))
def test_bbox_order_invalid(self):
self._expect_invalid(_zip_bytes(_middle_bytes([_page([_block("table", (218, 48, 41, 282))])])))
self._expect_invalid(
_zip_bytes(_middle_bytes([_page([_block("table", (218, 48, 41, 282))])]))
)
def test_bbox_int_degenerate(self):
# float 合法但 int() 后宽度为零: 专为 CHS shim 的裁剪路径兜底
self._expect_invalid(_zip_bytes(_middle_bytes([_page([_block("table", (1.2, 1.2, 1.8, 5))])])))
self._expect_invalid(
_zip_bytes(_middle_bytes([_page([_block("table", (1.2, 1.2, 1.8, 5))])]))
)
def test_bbox_non_finite(self):
self._expect_invalid(_zip_bytes(_middle_bytes([_page([_block("table", (1, 2, float("inf"), 4))])])))
self._expect_invalid(
_zip_bytes(_middle_bytes([_page([_block("table", (1, 2, float("inf"), 4))])]))
)
def test_type_missing(self):
block = {"bbox": [1, 2, 30, 40], "index": 0}
@@ -278,8 +284,13 @@ class TestMiddleJsonDefense:
class TestErrorTranslation:
@pytest.mark.parametrize(
("status", "exc_type"),
[(502, TransientError), (429, TransientError), (401, SourceDeadError),
(403, SourceDeadError), (404, RequestRejectedError)],
[
(502, TransientError),
(429, TransientError),
(401, SourceDeadError),
(403, SourceDeadError),
(404, RequestRejectedError),
],
)
async def test_http_status(self, status, exc_type):
t = _transport_for(_routes(text_resp=httpx.Response(status)))