Skip to content

Commit 9c99f33

Browse files
Set default values (from pdfRest) on optional client parameters
Assisted-by: Codex
1 parent 9ff3a86 commit 9c99f33

1 file changed

Lines changed: 24 additions & 25 deletions

File tree

src/pdfrest/client.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ def summarize_text(
21362136
self,
21372137
file: PdfRestFile | Sequence[PdfRestFile],
21382138
*,
2139-
target_word_count: int | None = 400,
2139+
target_word_count: int = 400,
21402140
summary_format: SummaryFormat = "overview",
21412141
pages: PdfPageSelection | None = None,
21422142
output_format: SummaryOutputFormat = "markdown",
@@ -2183,7 +2183,7 @@ def summarize_text_to_file(
21832183
self,
21842184
file: PdfRestFile | Sequence[PdfRestFile],
21852185
*,
2186-
target_word_count: int | None = 400,
2186+
target_word_count: int = 400,
21872187
summary_format: SummaryFormat = "overview",
21882188
pages: PdfPageSelection | None = None,
21892189
output_format: SummaryOutputFormat = "markdown",
@@ -2222,7 +2222,7 @@ def convert_to_markdown(
22222222
file: PdfRestFile | Sequence[PdfRestFile],
22232223
*,
22242224
pages: PdfPageSelection | None = None,
2225-
page_break_comments: bool | None = None,
2225+
page_break_comments: bool = False,
22262226
output: str | None = None,
22272227
extra_query: Query | None = None,
22282228
extra_headers: AnyMapping | None = None,
@@ -2234,11 +2234,10 @@ def convert_to_markdown(
22342234
payload: dict[str, Any] = {
22352235
"files": file,
22362236
"output_type": "file",
2237+
"page_break_comments": page_break_comments,
22372238
}
22382239
if pages is not None:
22392240
payload["pages"] = pages
2240-
if page_break_comments is not None:
2241-
payload["page_break_comments"] = page_break_comments
22422241
if output is not None:
22432242
payload["output"] = output
22442243

@@ -2818,20 +2817,21 @@ def convert_to_pdfa(
28182817
*,
28192818
output_type: PdfAType,
28202819
output: str | None = None,
2821-
rasterize_if_errors_encountered: bool | None = None,
2820+
rasterize_if_errors_encountered: bool = False,
28222821
extra_query: Query | None = None,
28232822
extra_headers: AnyMapping | None = None,
28242823
extra_body: Body | None = None,
28252824
timeout: TimeoutTypes | None = None,
28262825
) -> PdfRestFileBasedResponse:
28272826
"""Convert a PDF to a specified PDF/A version."""
28282827

2829-
payload: dict[str, Any] = {"files": file, "output_type": output_type}
2828+
payload: dict[str, Any] = {
2829+
"files": file,
2830+
"output_type": output_type,
2831+
"rasterize_if_errors_encountered": rasterize_if_errors_encountered,
2832+
}
28302833
if output is not None:
28312834
payload["output"] = output
2832-
if rasterize_if_errors_encountered is not None:
2833-
payload["rasterize_if_errors_encountered"] = rasterize_if_errors_encountered
2834-
28352835
return self._post_file_operation(
28362836
endpoint="/pdfa",
28372837
payload=payload,
@@ -3000,7 +3000,7 @@ def convert_to_jpeg(
30003000
smoothing: Literal["none", "all", "text", "line", "image"]
30013001
| Sequence[Literal["none", "all", "text", "line", "image"]]
30023002
| None = None,
3003-
jpeg_quality: int | None = None,
3003+
jpeg_quality: int = 75,
30043004
extra_query: Query | None = None,
30053005
extra_headers: AnyMapping | None = None,
30063006
extra_body: Body | None = None,
@@ -3012,15 +3012,14 @@ def convert_to_jpeg(
30123012
"files": files,
30133013
"resolution": resolution,
30143014
"color_model": color_model,
3015+
"jpeg_quality": jpeg_quality,
30153016
}
30163017
if output_prefix is not None:
30173018
payload["output_prefix"] = output_prefix
30183019
if page_range is not None:
30193020
payload["page_range"] = page_range
30203021
if smoothing is not None:
30213022
payload["smoothing"] = smoothing
3022-
if jpeg_quality is not None:
3023-
payload["jpeg_quality"] = jpeg_quality
30243023

30253024
return self._convert_to_graphic(
30263025
endpoint="/jpg",
@@ -3146,7 +3145,7 @@ async def summarize_text(
31463145
self,
31473146
file: PdfRestFile | Sequence[PdfRestFile],
31483147
*,
3149-
target_word_count: int | None = 400,
3148+
target_word_count: int = 400,
31503149
summary_format: SummaryFormat = "overview",
31513150
pages: PdfPageSelection | None = None,
31523151
output_format: SummaryOutputFormat = "markdown",
@@ -3193,7 +3192,7 @@ async def summarize_text_to_file(
31933192
self,
31943193
file: PdfRestFile | Sequence[PdfRestFile],
31953194
*,
3196-
target_word_count: int | None = 400,
3195+
target_word_count: int = 400,
31973196
summary_format: SummaryFormat = "overview",
31983197
pages: PdfPageSelection | None = None,
31993198
output_format: SummaryOutputFormat = "markdown",
@@ -3232,7 +3231,7 @@ async def convert_to_markdown(
32323231
file: PdfRestFile | Sequence[PdfRestFile],
32333232
*,
32343233
pages: PdfPageSelection | None = None,
3235-
page_break_comments: bool | None = None,
3234+
page_break_comments: bool = False,
32363235
output: str | None = None,
32373236
extra_query: Query | None = None,
32383237
extra_headers: AnyMapping | None = None,
@@ -3244,11 +3243,10 @@ async def convert_to_markdown(
32443243
payload: dict[str, Any] = {
32453244
"files": file,
32463245
"output_type": "file",
3246+
"page_break_comments": page_break_comments,
32473247
}
32483248
if pages is not None:
32493249
payload["pages"] = pages
3250-
if page_break_comments is not None:
3251-
payload["page_break_comments"] = page_break_comments
32523250
if output is not None:
32533251
payload["output"] = output
32543252

@@ -3870,19 +3868,21 @@ async def convert_to_pdfa(
38703868
*,
38713869
output_type: PdfAType,
38723870
output: str | None = None,
3873-
rasterize_if_errors_encountered: bool | None = None,
3871+
rasterize_if_errors_encountered: bool = False,
38743872
extra_query: Query | None = None,
38753873
extra_headers: AnyMapping | None = None,
38763874
extra_body: Body | None = None,
38773875
timeout: TimeoutTypes | None = None,
38783876
) -> PdfRestFileBasedResponse:
38793877
"""Asynchronously convert a PDF to a specified PDF/A version."""
38803878

3881-
payload: dict[str, Any] = {"files": file, "output_type": output_type}
3879+
payload: dict[str, Any] = {
3880+
"files": file,
3881+
"output_type": output_type,
3882+
"rasterize_if_errors_encountered": rasterize_if_errors_encountered,
3883+
}
38823884
if output is not None:
38833885
payload["output"] = output
3884-
if rasterize_if_errors_encountered is not None:
3885-
payload["rasterize_if_errors_encountered"] = rasterize_if_errors_encountered
38863886

38873887
return await self._post_file_operation(
38883888
endpoint="/pdfa",
@@ -4052,7 +4052,7 @@ async def convert_to_jpeg(
40524052
smoothing: Literal["none", "all", "text", "line", "image"]
40534053
| Sequence[Literal["none", "all", "text", "line", "image"]]
40544054
| None = None,
4055-
jpeg_quality: int | None = None,
4055+
jpeg_quality: int = 75,
40564056
extra_query: Query | None = None,
40574057
extra_headers: AnyMapping | None = None,
40584058
extra_body: Body | None = None,
@@ -4064,15 +4064,14 @@ async def convert_to_jpeg(
40644064
"files": files,
40654065
"resolution": resolution,
40664066
"color_model": color_model,
4067+
"jpeg_quality": jpeg_quality,
40674068
}
40684069
if output_prefix is not None:
40694070
payload["output_prefix"] = output_prefix
40704071
if page_range is not None:
40714072
payload["page_range"] = page_range
40724073
if smoothing is not None:
40734074
payload["smoothing"] = smoothing
4074-
if jpeg_quality is not None:
4075-
payload["jpeg_quality"] = jpeg_quality
40764075

40774076
return await self._convert_to_graphic(
40784077
endpoint="/jpg",

0 commit comments

Comments
 (0)