From 878eff203e5beea150136e15e9c940dda1b1874b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 05:18:42 +0100 Subject: [PATCH 1/3] Improve `raw` type --- src/vws/types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vws/types.py b/src/vws/types.py index 3e5e49aa..711da851 100644 --- a/src/vws/types.py +++ b/src/vws/types.py @@ -1,6 +1,7 @@ """Responses for requests to VWS and VWQ.""" from dataclasses import dataclass +from io import IOBase from beartype import beartype @@ -17,4 +18,4 @@ class Response: status_code: int headers: dict[str, str] request_body: bytes | str | None - raw: bytes + raw: IOBase From abbbb708b5a71f25ae8bb04fbc0e9db51bd759f3 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 05:33:10 +0100 Subject: [PATCH 2/3] Save tell-position in Response --- src/vws/types.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vws/types.py b/src/vws/types.py index 711da851..e6f59145 100644 --- a/src/vws/types.py +++ b/src/vws/types.py @@ -1,7 +1,6 @@ """Responses for requests to VWS and VWQ.""" from dataclasses import dataclass -from io import IOBase from beartype import beartype @@ -18,4 +17,4 @@ class Response: status_code: int headers: dict[str, str] request_body: bytes | str | None - raw: IOBase + tell_position: int From 943b215882fa0fff3e11da091dc449d7ca3d36ab Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 05:34:18 +0100 Subject: [PATCH 3/3] Update Response callers --- src/vws/query.py | 2 +- src/vws/vws.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vws/query.py b/src/vws/query.py index 17382d60..2380ba96 100644 --- a/src/vws/query.py +++ b/src/vws/query.py @@ -154,7 +154,7 @@ def query( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) if response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE: diff --git a/src/vws/vws.py b/src/vws/vws.py index 2acc2ca0..185af117 100644 --- a/src/vws/vws.py +++ b/src/vws/vws.py @@ -125,7 +125,7 @@ def _target_api_request( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), )