Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 7345162

Browse files
committed
Typing fixes in handlers.py
1 parent 472fa1e commit 7345162

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

camelot/handlers.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Functions to handle all operations on the PDF's."""
22

3+
from __future__ import annotations
4+
35
import multiprocessing as mp
46
import os
57
import sys
@@ -52,12 +54,16 @@ class PDFHandler:
5254
"""
5355

5456
def __init__(
55-
self, filepath: Union[StrByteType, Path], pages="1", password=None, debug=False
57+
self,
58+
filepath: StrByteType | Path | str,
59+
pages="1",
60+
password=None,
61+
debug=False,
5662
):
5763
self.debug = debug
5864
if is_url(filepath):
59-
filepath = download_url(filepath)
60-
self.filepath: Union[StrByteType, Path] = filepath
65+
filepath = download_url(str(filepath))
66+
self.filepath: StrByteType | Path | str = filepath
6167

6268
if isinstance(filepath, str) and not filepath.lower().endswith(".pdf"):
6369
raise NotImplementedError("File format not supported")
@@ -114,7 +120,7 @@ def _get_pages(self, pages):
114120
result.extend(range(p["start"], p["end"] + 1))
115121
return sorted(set(result))
116122

117-
def _save_page(self, filepath: Union[StrByteType, Path], page, temp):
123+
def _save_page(self, filepath: StrByteType | Path, page, temp):
118124
"""Saves specified page from PDF into a temporary directory.
119125
120126
Parameters

0 commit comments

Comments
 (0)