Skip to content

Commit 211e187

Browse files
convert-colors: Remove additional, unnecessary instances of profile
Assisted-by: Codex
1 parent 3301e85 commit 211e187

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

‎src/pdfrest/models/_internal.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,13 +1379,12 @@ class PdfConvertColorsPayload(BaseModel):
13791379
PdfConvertColorProfile,
13801380
Field(serialization_alias="color_profile"),
13811381
]
1382-
profile: Annotated[
1382+
custom_profile: Annotated[
13831383
list[PdfRestFile] | None,
13841384
Field(
13851385
default=None,
13861386
min_length=1,
13871387
max_length=1,
1388-
validation_alias=AliasChoices("profile", "profiles"),
13891388
serialization_alias="profile_id",
13901389
),
13911390
BeforeValidator(_ensure_list),
@@ -1420,27 +1419,27 @@ def _normalize_color_profile(cls, value: Any) -> Any:
14201419
if not _is_uploaded_file_value(color_profile):
14211420
return payload
14221421

1423-
if payload.get("profile") is not None or payload.get("profiles") is not None:
1422+
if payload.get("custom_profile") is not None:
14241423
msg = (
14251424
"Provide the custom profile file via color_profile only when "
14261425
"color_profile is a file."
14271426
)
14281427
raise ValueError(msg)
14291428

14301429
payload["color_profile"] = "custom"
1431-
payload["profile"] = color_profile
1430+
payload["custom_profile"] = color_profile
14321431
return payload
14331432

14341433
@model_validator(mode="after")
14351434
def _validate_profile_dependency(self) -> PdfConvertColorsPayload:
14361435
if self.color_profile == "custom":
1437-
if not self.profile:
1436+
if not self.custom_profile:
14381437
msg = (
14391438
"A custom color profile requires an uploaded ICC file passed "
14401439
"as color_profile."
14411440
)
14421441
raise ValueError(msg)
1443-
elif self.profile:
1442+
elif self.custom_profile:
14441443
msg = (
14451444
"A profile can only be provided by passing an uploaded ICC file "
14461445
"as color_profile."

‎tests/test_convert_colors.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def test_convert_colors_payload_profile_dependency_validation() -> None:
399399
{
400400
"files": [pdf_file],
401401
"color_profile": "srgb",
402-
"profile": _make_icc_file(),
402+
"custom_profile": _make_icc_file(),
403403
}
404404
)
405405

@@ -411,7 +411,7 @@ def test_convert_colors_payload_profile_dependency_validation() -> None:
411411
{
412412
"files": [pdf_file],
413413
"color_profile": _make_icc_file(),
414-
"profile": _make_icc_file(),
414+
"custom_profile": _make_icc_file(),
415415
}
416416
)
417417

0 commit comments

Comments
 (0)