Skip to content

Commit

Permalink
fix: thank you mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Jan 24, 2025
1 parent 8f46204 commit 3ab06b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/paves/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def make_poppler_args(dpi: int, width: int, height: int) -> List[str]:


@functools.singledispatch
def _popple(pdf, args: List[str]) -> None:
def _popple(pdf, tempdir: Path, args: List[str]) -> None:
pass


Expand Down Expand Up @@ -71,6 +71,7 @@ def _popple_doc(pdf: Document, tempdir: Path, args: List[str]) -> None:

@_popple.register(Page)
def _popple_page(pdf: Page, tempdir: Path, args: List[str]) -> None:
assert pdf.doc is not None # bug in PLAYA-PDF, oops, it cannot be None
pdfpdf = tempdir / "pdf.pdf"
with open(pdfpdf, "wb") as outfh:
outfh.write(pdf.doc.buffer)
Expand All @@ -80,9 +81,9 @@ def _popple_page(pdf: Page, tempdir: Path, args: List[str]) -> None:
"pdftoppm",
*args,
"-f",
page_number,
str(page_number),
"-l",
page_number,
str(page_number),
str(pdfpdf),
tempdir / "ppm",
],
Expand All @@ -93,6 +94,7 @@ def _popple_page(pdf: Page, tempdir: Path, args: List[str]) -> None:
@_popple.register(PageList)
def _popple_pages(pdf: PageList, tempdir: Path, args: List[str]) -> None:
pdfpdf = tempdir / "pdf.pdf"
assert pdf[0].doc is not None # bug in PLAYA-PDF, oops, it cannot be None
with open(pdfpdf, "wb") as outfh:
outfh.write(pdf[0].doc.buffer)
pages = sorted(page.page_idx + 1 for page in pdf)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ def test_popple():
assert len(images) == 5
images = list(popple(pdf.pages[[3, 4, 5, 9, 10]]))
assert len(images) == 5
images = list(popple(pdf.pages[1]))
assert len(images) == 1

0 comments on commit 3ab06b8

Please sign in to comment.