From 7345162c2c71ad4c948915344cbb0cfffb1e13a9 Mon Sep 17 00:00:00 2001 From: bosd Date: Fri, 18 Oct 2024 23:23:57 +0200 Subject: [PATCH] Typing fixes in handlers.py --- camelot/handlers.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/camelot/handlers.py b/camelot/handlers.py index 9bb076f6..53411642 100644 --- a/camelot/handlers.py +++ b/camelot/handlers.py @@ -1,5 +1,7 @@ """Functions to handle all operations on the PDF's.""" +from __future__ import annotations + import multiprocessing as mp import os import sys @@ -52,12 +54,16 @@ class PDFHandler: """ def __init__( - self, filepath: Union[StrByteType, Path], pages="1", password=None, debug=False + self, + filepath: StrByteType | Path | str, + pages="1", + password=None, + debug=False, ): self.debug = debug if is_url(filepath): - filepath = download_url(filepath) - self.filepath: Union[StrByteType, Path] = filepath + filepath = download_url(str(filepath)) + self.filepath: StrByteType | Path | str = filepath if isinstance(filepath, str) and not filepath.lower().endswith(".pdf"): raise NotImplementedError("File format not supported") @@ -114,7 +120,7 @@ def _get_pages(self, pages): result.extend(range(p["start"], p["end"] + 1)) return sorted(set(result)) - def _save_page(self, filepath: Union[StrByteType, Path], page, temp): + def _save_page(self, filepath: StrByteType | Path, page, temp): """Saves specified page from PDF into a temporary directory. Parameters