Fix: satisfy pyrefly in test_pdf_ops and clarify pdf_ops docstrings

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Trenton HandClaude Sonnet 5.5 committed 2026-10-03 15:03:31 -07:00
1 parent dcfe389909
commit 6d61214bba
2 files changed
+7 -2

No files matched your search

+6 -2
View File
@@ -39,7 +39,10 @@ def _require_positive(pages: Iterable[int]) -> None:
def rotate_pdf(src: Path, dst: Path, degrees: int) -> None:
"""Rotate every page relatively, in place, keeping document-level data."""
"""
Rotate every page relatively on the opened document, not a rebuild, so Info,
XMP and outlines are kept. ``src`` is not modified.
"""
with pikepdf.open(src) as pdf:
for page in pdf.pages:
page.rotate(degrees, relative=True)
@@ -49,7 +52,8 @@ def rotate_pdf(src: Path, dst: Path, degrees: int) -> None:
def remove_pages(src: Path, dst: Path, pages: Iterable[int]) -> None:
"""
Remove 1-indexed pages in place, keeping document-level data.
Remove 1-indexed pages from the opened document, not a rebuild, so Info, XMP
and outlines are kept. ``src`` is not modified.
Duplicates are ignored. Pages are removed highest first so earlier removals
never shift the index of later ones.
+1
View File
@@ -27,6 +27,7 @@ SIGNED = SRC_ROOT / "paperless" / "tests" / "samples" / "tesseract" / "signed.pd
def _page_fingerprint(page: pikepdf.Page) -> str:
contents = page.obj.get("/Contents")
assert contents is not None, "sample page has no /Contents"
streams = list(contents) if isinstance(contents, pikepdf.Array) else [contents]
return hashlib.sha1(b"".join(s.read_bytes() for s in streams)).hexdigest()