Skip to content

Commit 20ab18f

Browse files
committed
Use a variable for image type in src/
1 parent c347e77 commit 20ab18f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/vws/query.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
from vws.include_target_data import CloudRecoIncludeTargetData
2929
from vws.reports import QueryResult, TargetData
3030

31+
_ImageType = io.BytesIO | io.BufferedRandom
3132

32-
def _get_image_data(image: io.BytesIO | io.BufferedRandom) -> bytes:
33+
34+
def _get_image_data(image: _ImageType) -> bytes:
3335
"""Get the data of an image file."""
3436
original_tell = image.tell()
3537
image.seek(0)
@@ -61,7 +63,7 @@ def __init__(
6163

6264
def query(
6365
self,
64-
image: io.BytesIO | io.BufferedRandom,
66+
image: _ImageType,
6567
max_num_results: int = 1,
6668
include_target_data: CloudRecoIncludeTargetData = (
6769
CloudRecoIncludeTargetData.TOP

src/vws/vws.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import time
99
from datetime import date
1010
from http import HTTPMethod, HTTPStatus
11-
from io import BufferedRandom
1211
from urllib.parse import urljoin
1312

1413
import requests
@@ -48,8 +47,10 @@
4847

4948
from .exceptions.response import Response
5049

50+
_ImageType = io.BytesIO | io.BufferedRandom
5151

52-
def _get_image_data(image: io.BytesIO | BufferedRandom) -> bytes:
52+
53+
def _get_image_data(image: _ImageType) -> bytes:
5354
"""Get the data of an image file."""
5455
original_tell = image.tell()
5556
image.seek(0)
@@ -234,7 +235,7 @@ def add_target(
234235
self,
235236
name: str,
236237
width: float,
237-
image: io.BytesIO | io.BufferedRandom,
238+
image: _ImageType,
238239
application_metadata: str | None,
239240
*,
240241
active_flag: bool,
@@ -617,7 +618,7 @@ def update_target(
617618
target_id: str,
618619
name: str | None = None,
619620
width: float | None = None,
620-
image: io.BytesIO | io.BufferedRandom | None = None,
621+
image: _ImageType | None = None,
621622
active_flag: bool | None = None,
622623
application_metadata: str | None = None,
623624
) -> None:

0 commit comments

Comments
 (0)