Skip to content

Commit 211377e

Browse files
nickwinderclaude
andcommitted
Rename FileInputWithUrl to FileInput, add UrlFileInput alias
Replace the ambiguous FileInputWithUrl name with explicit type aliases: - LocalFileInput = Path | bytes | BinaryIO (unchanged) - UrlFileInput = str (new, explicit URL type) - FileInput = UrlFileInput | LocalFileInput (combined, replaces FileInputWithUrl) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ad96107 commit 211377e

File tree

8 files changed

+60
-59
lines changed

8 files changed

+60
-59
lines changed

src/nutrient_dws/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
ValidationError,
1313
)
1414
from nutrient_dws.inputs import (
15-
FileInputWithUrl,
15+
FileInput,
1616
LocalFileInput,
17+
UrlFileInput,
1718
is_remote_file_input,
1819
process_file_input,
1920
validate_file_input,
@@ -23,8 +24,9 @@
2324
__all__ = [
2425
"APIError",
2526
"AuthenticationError",
26-
"FileInputWithUrl",
27+
"FileInput",
2728
"LocalFileInput",
29+
"UrlFileInput",
2830
"NetworkError",
2931
"NutrientClient",
3032
"NutrientError",

src/nutrient_dws/builder/builder.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
NutrientClientOptions,
2727
)
2828
from nutrient_dws.inputs import (
29-
FileInputWithUrl,
29+
FileInput,
3030
NormalizedFileData,
3131
is_remote_file_input,
3232
process_file_input,
@@ -76,12 +76,12 @@ def __init__(self, client_options: NutrientClientOptions) -> None:
7676
"""
7777
super().__init__(client_options)
7878
self.build_instructions: BuildInstructions = {"parts": []}
79-
self.assets: dict[str, FileInputWithUrl] = {}
79+
self.assets: dict[str, FileInput] = {}
8080
self.asset_index = 0
8181
self.current_step = 0
8282
self.is_executed = False
8383

84-
def _register_asset(self, asset: FileInputWithUrl) -> str:
84+
def _register_asset(self, asset: FileInput) -> str:
8585
"""Register an asset in the workflow and return its key for use in actions.
8686
8787
Args:
@@ -188,7 +188,7 @@ def _cleanup(self) -> None:
188188

189189
def add_file_part(
190190
self,
191-
file: FileInputWithUrl,
191+
file: FileInput,
192192
options: FilePartOptions | None = None,
193193
actions: list[ApplicableAction] | None = None,
194194
) -> WorkflowWithPartsStage:
@@ -229,8 +229,8 @@ def add_file_part(
229229

230230
def add_html_part(
231231
self,
232-
html: FileInputWithUrl,
233-
assets: list[FileInputWithUrl] | None = None,
232+
html: FileInput,
233+
assets: list[FileInput] | None = None,
234234
options: HTMLPartOptions | None = None,
235235
actions: list[ApplicableAction] | None = None,
236236
) -> WorkflowWithPartsStage:

src/nutrient_dws/builder/constant.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections.abc import Callable
22
from typing import Any, Literal, Protocol, TypeVar, cast
33

4-
from nutrient_dws.inputs import FileInputWithUrl
4+
from nutrient_dws.inputs import FileInput
55
from nutrient_dws.types.build_actions import (
66
ApplyInstantJsonAction,
77
ApplyRedactionsAction,
@@ -53,7 +53,7 @@ class ActionWithFileInput(Protocol):
5353
"""Internal action type that holds FileInput for deferred registration."""
5454

5555
__needsFileRegistration: bool
56-
fileInput: FileInputWithUrl
56+
fileInput: FileInput
5757
createAction: Callable[[FileHandle], BuildAction]
5858

5959

@@ -133,7 +133,7 @@ def watermark_text(
133133

134134
@staticmethod
135135
def watermark_image(
136-
image: FileInputWithUrl, options: ImageWatermarkActionOptions | None = None
136+
image: FileInput, options: ImageWatermarkActionOptions | None = None
137137
) -> ActionWithFileInput:
138138
"""Create an image watermark action.
139139
@@ -163,7 +163,7 @@ class ImageWatermarkActionWithFileInput(ActionWithFileInput):
163163
__needsFileRegistration = True
164164

165165
def __init__(
166-
self, file_input: FileInputWithUrl, opts: ImageWatermarkActionOptions
166+
self, file_input: FileInput, opts: ImageWatermarkActionOptions
167167
):
168168
self.fileInput = file_input
169169
self.options = opts
@@ -196,7 +196,7 @@ def flatten(annotation_ids: list[str | int] | None = None) -> FlattenAction:
196196
return result
197197

198198
@staticmethod
199-
def apply_instant_json(file: FileInputWithUrl) -> ActionWithFileInput:
199+
def apply_instant_json(file: FileInput) -> ActionWithFileInput:
200200
"""Create an apply Instant JSON action.
201201
202202
Args:
@@ -209,7 +209,7 @@ def apply_instant_json(file: FileInputWithUrl) -> ActionWithFileInput:
209209
class ApplyInstantJsonActionWithFileInput(ActionWithFileInput):
210210
__needsFileRegistration = True
211211

212-
def __init__(self, file_input: FileInputWithUrl):
212+
def __init__(self, file_input: FileInput):
213213
self.fileInput = file_input
214214

215215
def createAction(self, fileHandle: FileHandle) -> ApplyInstantJsonAction:
@@ -222,7 +222,7 @@ def createAction(self, fileHandle: FileHandle) -> ApplyInstantJsonAction:
222222

223223
@staticmethod
224224
def apply_xfdf(
225-
file: FileInputWithUrl, options: ApplyXfdfActionOptions | None = None
225+
file: FileInput, options: ApplyXfdfActionOptions | None = None
226226
) -> ActionWithFileInput:
227227
"""Create an apply XFDF action.
228228
@@ -240,7 +240,7 @@ class ApplyXfdfActionWithFileInput(ActionWithFileInput):
240240
__needsFileRegistration = True
241241

242242
def __init__(
243-
self, file_input: FileInputWithUrl, opts: ApplyXfdfActionOptions | None
243+
self, file_input: FileInput, opts: ApplyXfdfActionOptions | None
244244
):
245245
self.fileInput = file_input
246246
self.options = opts or {}

src/nutrient_dws/builder/staged_builders.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from nutrient_dws.types.build_actions import BuildAction
1111

1212
if TYPE_CHECKING:
13-
from nutrient_dws.inputs import FileInputWithUrl
13+
from nutrient_dws.inputs import FileInput
1414
from nutrient_dws.types.analyze_response import AnalyzeBuildResponse
1515
from nutrient_dws.types.build_output import (
1616
ImageOutputOptions,
@@ -114,7 +114,7 @@ class WorkflowInitialStage(ABC):
114114
@abstractmethod
115115
def add_file_part(
116116
self,
117-
file: FileInputWithUrl,
117+
file: FileInput,
118118
options: FilePartOptions | None = None,
119119
actions: list[ApplicableAction] | None = None,
120120
) -> WorkflowWithPartsStage:
@@ -124,8 +124,8 @@ def add_file_part(
124124
@abstractmethod
125125
def add_html_part(
126126
self,
127-
html: FileInputWithUrl,
128-
assets: list[FileInputWithUrl] | None = None,
127+
html: FileInput,
128+
assets: list[FileInput] | None = None,
129129
options: HTMLPartOptions | None = None,
130130
actions: list[ApplicableAction] | None = None,
131131
) -> WorkflowWithPartsStage:

src/nutrient_dws/client.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
send_request,
2626
)
2727
from nutrient_dws.inputs import (
28-
FileInputWithUrl,
28+
FileInput,
2929
LocalFileInput,
3030
is_valid_pdf,
3131
process_file_input,
@@ -400,7 +400,7 @@ async def sign(
400400

401401
async def watermark_text(
402402
self,
403-
file: FileInputWithUrl,
403+
file: FileInput,
404404
text: str,
405405
options: TextWatermarkActionOptions | None = None,
406406
) -> BufferOutput:
@@ -444,8 +444,8 @@ async def watermark_text(
444444

445445
async def watermark_image(
446446
self,
447-
file: FileInputWithUrl,
448-
image: FileInputWithUrl,
447+
file: FileInput,
448+
image: FileInput,
449449
options: ImageWatermarkActionOptions | None = None,
450450
) -> BufferOutput:
451451
"""Add an image watermark to a document.
@@ -497,7 +497,7 @@ async def watermark_image(
497497

498498
async def convert(
499499
self,
500-
file: FileInputWithUrl,
500+
file: FileInput,
501501
target_format: OutputFormat,
502502
) -> BufferOutput | ContentOutput | JsonContentOutput:
503503
"""Convert a document to a different format.
@@ -560,7 +560,7 @@ async def convert(
560560

561561
async def ocr(
562562
self,
563-
file: FileInputWithUrl,
563+
file: FileInput,
564564
language: OcrLanguage | list[OcrLanguage],
565565
) -> BufferOutput:
566566
"""Perform OCR (Optical Character Recognition) on a document.
@@ -597,7 +597,7 @@ async def ocr(
597597

598598
async def extract_text(
599599
self,
600-
file: FileInputWithUrl,
600+
file: FileInput,
601601
pages: PageRange | None = None,
602602
) -> JsonContentOutput:
603603
"""Extract text content from a document.
@@ -648,7 +648,7 @@ async def extract_text(
648648

649649
async def extract_table(
650650
self,
651-
file: FileInputWithUrl,
651+
file: FileInput,
652652
pages: PageRange | None = None,
653653
) -> JsonContentOutput:
654654
"""Extract table content from a document.
@@ -700,7 +700,7 @@ async def extract_table(
700700

701701
async def extract_key_value_pairs(
702702
self,
703-
file: FileInputWithUrl,
703+
file: FileInput,
704704
pages: PageRange | None = None,
705705
) -> JsonContentOutput:
706706
"""Extract key value pair content from a document.
@@ -755,7 +755,7 @@ async def extract_key_value_pairs(
755755

756756
async def set_page_labels(
757757
self,
758-
pdf: FileInputWithUrl,
758+
pdf: FileInput,
759759
labels: list[Label],
760760
) -> BufferOutput:
761761
"""Set page labels for a PDF document.
@@ -794,7 +794,7 @@ async def set_page_labels(
794794

795795
async def password_protect(
796796
self,
797-
file: FileInputWithUrl,
797+
file: FileInput,
798798
user_password: str,
799799
owner_password: str,
800800
permissions: list[PDFUserPermission] | None = None,
@@ -842,7 +842,7 @@ async def password_protect(
842842

843843
async def set_metadata(
844844
self,
845-
pdf: FileInputWithUrl,
845+
pdf: FileInput,
846846
metadata: Metadata,
847847
) -> BufferOutput:
848848
"""Set metadata for a PDF document.
@@ -881,8 +881,8 @@ async def set_metadata(
881881

882882
async def apply_instant_json(
883883
self,
884-
pdf: FileInputWithUrl,
885-
instant_json_file: FileInputWithUrl,
884+
pdf: FileInput,
885+
instant_json_file: FileInput,
886886
) -> BufferOutput:
887887
"""Apply Instant JSON to a document.
888888
This is a convenience method that uses the workflow builder.
@@ -922,8 +922,8 @@ async def apply_instant_json(
922922

923923
async def apply_xfdf(
924924
self,
925-
pdf: FileInputWithUrl,
926-
xfdf_file: FileInputWithUrl,
925+
pdf: FileInput,
926+
xfdf_file: FileInput,
927927
options: ApplyXfdfActionOptions | None = None,
928928
) -> BufferOutput:
929929
"""Apply XFDF to a document.
@@ -969,7 +969,7 @@ async def apply_xfdf(
969969

970970
return cast("BufferOutput", self._process_typed_workflow_result(result))
971971

972-
async def merge(self, files: list[FileInputWithUrl]) -> BufferOutput:
972+
async def merge(self, files: list[FileInput]) -> BufferOutput:
973973
"""Merge multiple documents into a single document.
974974
This is a convenience method that uses the workflow builder.
975975
@@ -1013,7 +1013,7 @@ async def merge(self, files: list[FileInputWithUrl]) -> BufferOutput:
10131013

10141014
async def flatten(
10151015
self,
1016-
pdf: FileInputWithUrl,
1016+
pdf: FileInput,
10171017
annotation_ids: list[str | int] | None = None,
10181018
) -> BufferOutput:
10191019
"""Flatten annotations in a PDF document.
@@ -1147,7 +1147,7 @@ async def create_redactions_ai(
11471147

11481148
async def create_redactions_preset(
11491149
self,
1150-
pdf: FileInputWithUrl,
1150+
pdf: FileInput,
11511151
preset: SearchPreset,
11521152
redaction_state: Literal["stage", "apply"] = "stage",
11531153
pages: PageRange | None = None,
@@ -1213,7 +1213,7 @@ async def create_redactions_preset(
12131213

12141214
async def create_redactions_regex(
12151215
self,
1216-
pdf: FileInputWithUrl,
1216+
pdf: FileInput,
12171217
regex: str,
12181218
redaction_state: Literal["stage", "apply"] = "stage",
12191219
pages: PageRange | None = None,
@@ -1279,7 +1279,7 @@ async def create_redactions_regex(
12791279

12801280
async def create_redactions_text(
12811281
self,
1282-
pdf: FileInputWithUrl,
1282+
pdf: FileInput,
12831283
text: str,
12841284
redaction_state: Literal["stage", "apply"] = "stage",
12851285
pages: PageRange | None = None,
@@ -1343,7 +1343,7 @@ async def create_redactions_text(
13431343

13441344
return cast("BufferOutput", self._process_typed_workflow_result(result))
13451345

1346-
async def apply_redactions(self, pdf: FileInputWithUrl) -> BufferOutput:
1346+
async def apply_redactions(self, pdf: FileInput) -> BufferOutput:
13471347
"""Apply staged redaction into the PDF.
13481348
13491349
**Note**: URLs are passed to the server for secure server-side fetching.
@@ -1380,7 +1380,7 @@ async def apply_redactions(self, pdf: FileInputWithUrl) -> BufferOutput:
13801380

13811381
async def rotate(
13821382
self,
1383-
pdf: FileInputWithUrl,
1383+
pdf: FileInput,
13841384
angle: Literal[90, 180, 270],
13851385
pages: PageRange | None = None,
13861386
) -> BufferOutput:
@@ -1451,7 +1451,7 @@ async def rotate(
14511451
return cast("BufferOutput", self._process_typed_workflow_result(result))
14521452

14531453
async def add_page(
1454-
self, pdf: FileInputWithUrl, count: int = 1, index: int | None = None
1454+
self, pdf: FileInput, count: int = 1, index: int | None = None
14551455
) -> BufferOutput:
14561456
"""Add blank pages to a document.
14571457
This is a convenience method that uses the workflow builder.
@@ -1514,7 +1514,7 @@ async def add_page(
15141514
return cast("BufferOutput", self._process_typed_workflow_result(result))
15151515

15161516
async def split(
1517-
self, pdf: FileInputWithUrl, page_ranges: list[PageRange]
1517+
self, pdf: FileInput, page_ranges: list[PageRange]
15181518
) -> list[BufferOutput]:
15191519
"""Split a PDF document into multiple parts based on page ranges.
15201520
This is a convenience method that uses the workflow builder.
@@ -1569,7 +1569,7 @@ async def create_split_pdf(page_range: PageRange) -> BufferOutput:
15691569
return results
15701570

15711571
async def duplicate_pages(
1572-
self, pdf: FileInputWithUrl, page_indices: list[int]
1572+
self, pdf: FileInput, page_indices: list[int]
15731573
) -> BufferOutput:
15741574
"""Create a new PDF containing only the specified pages in the order provided.
15751575
This is a convenience method that uses the workflow builder.
@@ -1620,7 +1620,7 @@ async def duplicate_pages(
16201620
return cast("BufferOutput", self._process_typed_workflow_result(result))
16211621

16221622
async def delete_pages(
1623-
self, pdf: FileInputWithUrl, page_indices: list[int]
1623+
self, pdf: FileInput, page_indices: list[int]
16241624
) -> BufferOutput:
16251625
"""Delete pages from a PDF document.
16261626
This is a convenience method that uses the workflow builder.
@@ -1699,7 +1699,7 @@ async def delete_pages(
16991699

17001700
async def optimize(
17011701
self,
1702-
pdf: FileInputWithUrl,
1702+
pdf: FileInput,
17031703
options: OptimizePdf | None = None,
17041704
) -> BufferOutput:
17051705
"""Optimize a PDF document for size reduction.

0 commit comments

Comments
 (0)