Skip to content

Commit 57837bc

Browse files
authored
fix: resolve duplicate code (#29)
1 parent c6bee06 commit 57837bc

3 files changed

Lines changed: 2 additions & 14 deletions

File tree

src/writerai/_base_client.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ def _build_request(
510510
params = _merge_mappings(self.default_query, options.params)
511511
content_type = headers.get("Content-Type")
512512
files = options.files
513-
content = options.content
514513

515514
# If the given Content-Type header is multipart/form-data then it
516515
# has to be removed so that httpx can generate the header with
@@ -581,7 +580,6 @@ def _build_request(
581580
# so that passing a `TypedDict` doesn't cause an error.
582581
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
583582
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
584-
content=content,
585583
**kwargs,
586584
)
587585

@@ -1290,11 +1288,7 @@ def post(
12901288
url=path,
12911289
json_data=body,
12921290
files=to_httpx_files(files),
1293-
content=(
1294-
get_file_content(_transform_file(binary_request))
1295-
if binary_request is not None
1296-
else content
1297-
),
1291+
content=(get_file_content(_transform_file(binary_request)) if binary_request is not None else content),
12981292
**options,
12991293
)
13001294
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
@@ -1876,9 +1870,7 @@ async def post(
18761870
json_data=body,
18771871
files=await async_to_httpx_files(files),
18781872
content=(
1879-
get_file_content(await _async_transform_file(binary_request))
1880-
if binary_request is not None
1881-
else content
1873+
get_file_content(await _async_transform_file(binary_request)) if binary_request is not None else content
18821874
),
18831875
**options,
18841876
)

src/writerai/_models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
Timeout,
4646
NotGiven,
4747
AnyMapping,
48-
HttpxFileContent,
4948
HttpxRequestFiles,
5049
)
5150
from ._utils import (
@@ -800,7 +799,6 @@ class FinalRequestOptionsInput(TypedDict, total=False):
800799
max_retries: int
801800
timeout: float | Timeout | None
802801
files: HttpxRequestFiles | None
803-
content: HttpxFileContent | None
804802
idempotency_key: str
805803
content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None]
806804
json_data: Body
@@ -817,7 +815,6 @@ class FinalRequestOptions(pydantic.BaseModel):
817815
max_retries: Union[int, NotGiven] = NotGiven()
818816
timeout: Union[float, Timeout, None, NotGiven] = NotGiven()
819817
files: Union[HttpxRequestFiles, None] = None
820-
content: Union[HttpxFileContent, None] = None
821818
idempotency_key: Union[str, None] = None
822819
post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
823820
follow_redirects: Union[bool, None] = None

src/writerai/resources/files.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import httpx
88

99
from ..types import file_list_params, file_retry_params, file_upload_params
10-
from .._files import _transform_file, get_file_content, _async_transform_file
1110
from .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, SequenceNotStr, omit, not_given
1211
from .._utils import path_template, maybe_transform, async_maybe_transform
1312
from .._compat import cached_property

0 commit comments

Comments
 (0)