Skip to content

Release/3.0.0#45

Merged
nickwinder merged 7 commits intomainfrom
austin/release-3.0.0
Feb 18, 2026
Merged

Release/3.0.0#45
nickwinder merged 7 commits intomainfrom
austin/release-3.0.0

Conversation

@HungKNguyen
Copy link
Collaborator

Apply similar changes to PSPDFKit-labs/nutrient-dws-client-typescript#8

Cutting for release under v3.0

Copy link
Contributor

@nickwinder nickwinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick pass. Worth answering my comment before I look again

HungKNguyen and others added 3 commits February 2, 2026 22:28
Co-authored-by: Nick Winder <nfxdevelopment@gmail.com>
Co-authored-by: Nick Winder <nfxdevelopment@gmail.com>
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>
@nickwinder
Copy link
Contributor

Code review

Found 2 issues:

  1. delete_pages() raises the wrong error when called with only negative indices (e.g., delete_pages(pdf, [-1])). The algorithm at line 1671 skips all negative indices with if delete_index >= 0, leaving page_ranges empty. The guard at line 1684 then also short-circuits because any(i >= 0 for i in delete_indices) is False, so no suffix range is appended. The result is that delete_pages(pdf, [-1]) raises ValidationError("You cannot delete all pages from a document") instead of deleting the last page. The docstring at line 1625 explicitly documents negative index support with the example [0, -1, -2].

for delete_index in delete_indices:
# Skip negative indices in this calculation - they represent "from end"
if delete_index >= 0:
if current_page < delete_index:
page_ranges.append(
normalize_page_params(
{"start": current_page, "end": delete_index - 1}
)
)
current_page = delete_index + 1
# Add remaining pages to end (use -1 for last page) add if we have positive indices processed
if (
current_page >= 0
and len(delete_indices) > 0
and any(i >= 0 for i in delete_indices)
):
page_ranges.append(
normalize_page_params({"start": current_page, "end": -1})
)
if len(page_ranges) == 0:
raise ValidationError("You cannot delete all pages from a document")

  1. rotate() drops all pages before the rotation range when start is negative. The check if start > 0 at line 1426 fails for negative values (e.g., start = -3), so the "pages before the rotation range" part is never added to the workflow. For a 10-page document, rotate(pdf, 90, {'start': -3, 'end': -1}) produces a 3-page PDF (only the rotated pages) instead of a 10-page PDF with the last 3 pages rotated. The docstring at line 1381 states the method returns "The entire document with specified pages rotated" and includes this exact negative-index pattern as an example.

# Add pages before the rotation range
if start > 0:
part_options = cast(
"FilePartOptions",
{"pages": {"start": 0, "end": start - 1}},
)
workflow = workflow.add_file_part(pdf, part_options)
# Add the rotation range
part_options = cast(
"FilePartOptions", {"pages": {"start": start, "end": end}}

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

nickwinder and others added 2 commits February 18, 2026 14:24
- rotate(): change `start > 0` to `start != 0` so prefix pages are
  included when a negative start index is used (e.g. start=-3)
- delete_pages(): rewrite keep-range algorithm to handle negative
  delete indices; previously all-negative inputs raised a spurious
  ValidationError instead of keeping the correct page range

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- pyproject.toml: add D102 to tests/* per-file-ignores so test methods
  are not required to have docstrings (the comment indicated this intent
  but the empty array had no effect)
- test_client.py: remove unused `result` assignment in
  test_password_protect_pdf_with_permissions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nickwinder nickwinder self-assigned this Feb 18, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nickwinder nickwinder merged commit 7457a52 into main Feb 18, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments