Skip to content

Commit 6382b7a

Browse files
committed
Revert "Accept all IO[bytes] as image type"
This reverts commit 50b63b1.
1 parent 50b63b1 commit 6382b7a

File tree

6 files changed

+36
-32
lines changed

6 files changed

+36
-32
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Changelog
44
Next
55
----
66

7-
* Be more flexible in the types of images accepted.
7+
2025.03.10.1
8+
------------
89

910
2025.03.10
1011
----------

src/vws/query.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"""
44

55
import datetime
6+
import io
67
import json
78
from http import HTTPMethod, HTTPStatus
8-
from typing import IO, Any
9+
from typing import Any, BinaryIO
910
from urllib.parse import urljoin
1011

1112
import requests
@@ -28,7 +29,7 @@
2829
from vws.reports import QueryResult, TargetData
2930
from vws.response import Response
3031

31-
_ImageType = IO[bytes]
32+
_ImageType = io.BytesIO | BinaryIO
3233

3334

3435
@beartype

src/vws/vws.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"""
44

55
import base64
6+
import io
67
import json
78
import time
89
from datetime import date
910
from http import HTTPMethod, HTTPStatus
10-
from typing import IO
11+
from typing import BinaryIO
1112
from urllib.parse import urljoin
1213

1314
import requests
@@ -46,7 +47,7 @@
4647
)
4748
from vws.response import Response
4849

49-
_ImageType = IO[bytes]
50+
_ImageType = io.BytesIO | BinaryIO
5051

5152

5253
@beartype

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io
66
from collections.abc import Generator
77
from pathlib import Path
8-
from typing import IO, BinaryIO, Literal
8+
from typing import BinaryIO, Literal
99

1010
import pytest
1111
from mock_vws import MockVWS
@@ -70,7 +70,7 @@ def image(
7070
request: pytest.FixtureRequest,
7171
high_quality_image: io.BytesIO,
7272
image_file: BinaryIO,
73-
) -> IO[bytes]:
73+
) -> io.BytesIO | BinaryIO:
7474
"""
7575
An image in any of the types that the API accepts.
7676
"""

tests/test_query.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Tests for the ``CloudRecoService`` querying functionality.
33
"""
44

5+
import io
56
import uuid
6-
from typing import IO
7+
from typing import BinaryIO
78

89
from mock_vws import MockVWS
910
from mock_vws.database import VuforiaDatabase
@@ -20,7 +21,7 @@ class TestQuery:
2021
@staticmethod
2122
def test_no_matches(
2223
cloud_reco_client: CloudRecoService,
23-
image: IO[bytes],
24+
image: io.BytesIO | BinaryIO,
2425
) -> None:
2526
"""
2627
An empty list is returned if there are no matches.
@@ -32,7 +33,7 @@ def test_no_matches(
3233
def test_match(
3334
vws_client: VWS,
3435
cloud_reco_client: CloudRecoService,
35-
image: IO[bytes],
36+
image: io.BytesIO | BinaryIO,
3637
) -> None:
3738
"""
3839
Details of matching targets are returned.
@@ -55,7 +56,7 @@ class TestCustomBaseVWQURL:
5556
"""
5657

5758
@staticmethod
58-
def test_custom_base_url(image: IO[bytes]) -> None:
59+
def test_custom_base_url(image: io.BytesIO | BinaryIO) -> None:
5960
"""
6061
It is possible to use query a target to a database under a custom VWQ
6162
URL.
@@ -100,7 +101,7 @@ class TestMaxNumResults:
100101
def test_default(
101102
vws_client: VWS,
102103
cloud_reco_client: CloudRecoService,
103-
image: IO[bytes],
104+
image: io.BytesIO | BinaryIO,
104105
) -> None:
105106
"""
106107
By default the maximum number of results is 1.
@@ -128,7 +129,7 @@ def test_default(
128129
def test_custom(
129130
vws_client: VWS,
130131
cloud_reco_client: CloudRecoService,
131-
image: IO[bytes],
132+
image: io.BytesIO | BinaryIO,
132133
) -> None:
133134
"""
134135
It is possible to set a custom ``max_num_results``.
@@ -174,7 +175,7 @@ class TestIncludeTargetData:
174175
def test_default(
175176
vws_client: VWS,
176177
cloud_reco_client: CloudRecoService,
177-
image: IO[bytes],
178+
image: io.BytesIO | BinaryIO,
178179
) -> None:
179180
"""
180181
By default, target data is only returned in the top match.
@@ -206,7 +207,7 @@ def test_default(
206207
def test_top(
207208
vws_client: VWS,
208209
cloud_reco_client: CloudRecoService,
209-
image: IO[bytes],
210+
image: io.BytesIO | BinaryIO,
210211
) -> None:
211212
"""
212213
When ``CloudRecoIncludeTargetData.TOP`` is given, target data is only
@@ -240,7 +241,7 @@ def test_top(
240241
def test_none(
241242
vws_client: VWS,
242243
cloud_reco_client: CloudRecoService,
243-
image: IO[bytes],
244+
image: io.BytesIO | BinaryIO,
244245
) -> None:
245246
"""
246247
When ``CloudRecoIncludeTargetData.NONE`` is given, target data is not
@@ -274,7 +275,7 @@ def test_none(
274275
def test_all(
275276
vws_client: VWS,
276277
cloud_reco_client: CloudRecoService,
277-
image: IO[bytes],
278+
image: io.BytesIO | BinaryIO,
278279
) -> None:
279280
"""
280281
When ``CloudRecoIncludeTargetData.ALL`` is given, target data is

tests/test_vws.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import io
88
import secrets
99
import uuid
10-
from typing import IO
10+
from typing import BinaryIO
1111

1212
import pytest
1313
from freezegun import freeze_time
@@ -37,7 +37,7 @@ class TestAddTarget:
3737
@pytest.mark.parametrize(argnames="active_flag", argvalues=[True, False])
3838
def test_add_target(
3939
vws_client: VWS,
40-
image: IO[bytes],
40+
image: io.BytesIO | BinaryIO,
4141
application_metadata: bytes | None,
4242
cloud_reco_client: CloudRecoService,
4343
*,
@@ -81,7 +81,7 @@ def test_add_target(
8181
@staticmethod
8282
def test_add_two_targets(
8383
vws_client: VWS,
84-
image: IO[bytes],
84+
image: io.BytesIO | BinaryIO,
8585
) -> None:
8686
"""No exception is raised when adding two targets with different names.
8787
@@ -103,7 +103,7 @@ class TestCustomBaseVWSURL:
103103
"""
104104

105105
@staticmethod
106-
def test_custom_base_url(image: IO[bytes]) -> None:
106+
def test_custom_base_url(image: io.BytesIO | BinaryIO) -> None:
107107
"""
108108
It is possible to use add a target to a database under a custom VWS
109109
URL.
@@ -135,7 +135,7 @@ class TestListTargets:
135135
@staticmethod
136136
def test_list_targets(
137137
vws_client: VWS,
138-
image: IO[bytes],
138+
image: io.BytesIO | BinaryIO,
139139
) -> None:
140140
"""
141141
It is possible to get a list of target IDs.
@@ -165,7 +165,7 @@ class TestDelete:
165165
@staticmethod
166166
def test_delete_target(
167167
vws_client: VWS,
168-
image: IO[bytes],
168+
image: io.BytesIO | BinaryIO,
169169
) -> None:
170170
"""
171171
It is possible to delete a target.
@@ -192,7 +192,7 @@ class TestGetTargetSummaryReport:
192192
@staticmethod
193193
def test_get_target_summary_report(
194194
vws_client: VWS,
195-
image: IO[bytes],
195+
image: io.BytesIO | BinaryIO,
196196
) -> None:
197197
"""
198198
Details of a target are returned by ``get_target_summary_report``.
@@ -294,7 +294,7 @@ class TestGetTargetRecord:
294294
@staticmethod
295295
def test_get_target_record(
296296
vws_client: VWS,
297-
image: IO[bytes],
297+
image: io.BytesIO | BinaryIO,
298298
) -> None:
299299
"""
300300
Details of a target are returned by ``get_target_record``.
@@ -369,7 +369,7 @@ class TestWaitForTargetProcessed:
369369
@staticmethod
370370
def test_wait_for_target_processed(
371371
vws_client: VWS,
372-
image: IO[bytes],
372+
image: io.BytesIO | BinaryIO,
373373
) -> None:
374374
"""
375375
It is possible to wait until a target is processed.
@@ -389,7 +389,7 @@ def test_wait_for_target_processed(
389389

390390
@staticmethod
391391
def test_default_seconds_between_requests(
392-
image: IO[bytes],
392+
image: io.BytesIO | BinaryIO,
393393
) -> None:
394394
"""
395395
By default, 0.2 seconds are waited between polling requests.
@@ -441,7 +441,7 @@ def test_default_seconds_between_requests(
441441

442442
@staticmethod
443443
def test_custom_seconds_between_requests(
444-
image: IO[bytes],
444+
image: io.BytesIO | BinaryIO,
445445
) -> None:
446446
"""
447447
It is possible to customize the time waited between polling requests.
@@ -492,7 +492,7 @@ def test_custom_seconds_between_requests(
492492
assert report.request_usage == expected_requests
493493

494494
@staticmethod
495-
def test_custom_timeout(image: IO[bytes]) -> None:
495+
def test_custom_timeout(image: io.BytesIO | BinaryIO) -> None:
496496
"""
497497
It is possible to set a maximum timeout.
498498
"""
@@ -538,7 +538,7 @@ class TestGetDuplicateTargets:
538538
@staticmethod
539539
def test_get_duplicate_targets(
540540
vws_client: VWS,
541-
image: IO[bytes],
541+
image: io.BytesIO | BinaryIO,
542542
) -> None:
543543
"""
544544
It is possible to get the IDs of similar targets.
@@ -572,7 +572,7 @@ class TestUpdateTarget:
572572
@staticmethod
573573
def test_update_target(
574574
vws_client: VWS,
575-
image: IO[bytes],
575+
image: io.BytesIO | BinaryIO,
576576
different_high_quality_image: io.BytesIO,
577577
cloud_reco_client: CloudRecoService,
578578
) -> None:
@@ -633,7 +633,7 @@ def test_update_target(
633633
@staticmethod
634634
def test_no_fields_given(
635635
vws_client: VWS,
636-
image: IO[bytes],
636+
image: io.BytesIO | BinaryIO,
637637
) -> None:
638638
"""
639639
It is possible to give no update fields.

0 commit comments

Comments
 (0)