From cf90ae2da98b4ea61e6834f0f0fb7ee96dbf23f6 Mon Sep 17 00:00:00 2001 From: Andrew Baumann Date: Tue, 12 Oct 2021 13:52:29 -0700 Subject: [PATCH 1/2] use new pdfminer release, with type annotations Unfortunately broken, due to the absence of https://github.com/pdfminer/pdfminer.six/pull/679 --- mypy.ini | 14 -------------- pdfannots/__init__.py | 3 +-- pdfannots/types.py | 2 +- requirements.txt | 2 +- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/mypy.ini b/mypy.ini index dbda9f0..7132412 100644 --- a/mypy.ini +++ b/mypy.ini @@ -14,17 +14,3 @@ warn_unused_ignores = True warn_return_any = True no_implicit_reexport = True strict_equality = True - -[mypy-pdfannots.*] -# temporary, for https://github.com/pdfminer/pdfminer.six/pull/661 -warn_unused_ignores = False - -[mypy-pdfminer.*] -ignore_missing_imports = True -disallow_untyped_calls = False -disallow_untyped_defs = False -check_untyped_defs = False -warn_unused_ignores = False - -[mypy-cryptography.hazmat.*] -ignore_missing_imports = True diff --git a/pdfannots/__init__.py b/pdfannots/__init__.py index b0fd150..5a5fd49 100644 --- a/pdfannots/__init__.py +++ b/pdfannots/__init__.py @@ -187,8 +187,7 @@ def walk_number_tree(td: typing.Dict[typing.Any, typing.Any] yield prefix + label -class _PDFProcessor(PDFLayoutAnalyzer): # type:ignore - # (pdfminer lacks type annotations) +class _PDFProcessor(PDFLayoutAnalyzer): """ PDF processor class. diff --git a/pdfannots/types.py b/pdfannots/types.py index d641050..9f49882 100644 --- a/pdfannots/types.py +++ b/pdfannots/types.py @@ -194,7 +194,7 @@ def __lt__(self, other: typing.Any) -> bool: def item_hit(self, item: LTComponent) -> bool: """Is this pos within the bounding box of the given PDF component?""" - return (self.x >= item.x0 # type: ignore [no-any-return] + return (self.x >= item.x0 and self.x <= item.x1 and self.y >= item.y0 and self.y <= item.y1) diff --git a/requirements.txt b/requirements.txt index 65addad..0a0e0ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ # pip requirements for pdfannots # Use as: pip3 install -r requirements.txt -pdfminer.six == 20201018 +pdfminer.six == 20211012 From 05e90fdff1cf631f72dd42b06cb969f856eb9623 Mon Sep 17 00:00:00 2001 From: Andrew Baumann Date: Sat, 19 Mar 2022 13:16:44 -0700 Subject: [PATCH 2/2] use new pdfminer release for type annotations --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0a0e0ca..b9ce344 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ # pip requirements for pdfannots # Use as: pip3 install -r requirements.txt -pdfminer.six == 20211012 +pdfminer.six == 20220319