From be1550189e10717f6827dbb7009d6e8c8b3f4c62 Mon Sep 17 00:00:00 2001 From: Andrew Baumann Date: Sat, 21 Aug 2021 10:13:58 -0700 Subject: [PATCH] silence missing imports, (maybe?) hook to tox --- mypy.ini | 5 +++-- pdfminer/ccitt.py | 2 +- pdfminer/image.py | 2 +- setup.py | 2 +- tox.ini | 1 + 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mypy.ini b/mypy.ini index c276f0d3..8953a1a3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -4,7 +4,7 @@ disallow_any_generics = True disallow_subclassing_any = True #disallow_untyped_calls = True #disallow_untyped_defs = True -#disallow_incomplete_defs = True +disallow_incomplete_defs = True #check_untyped_defs = True disallow_untyped_decorators = True no_implicit_optional = True @@ -14,5 +14,6 @@ warn_return_any = True no_implicit_reexport = True strict_equality = True -[mypy-pdfminer.*] +[mypy-cryptography.hazmat.*] ignore_missing_imports = True + diff --git a/pdfminer/ccitt.py b/pdfminer/ccitt.py index 1c00eb0e..8ae123b5 100644 --- a/pdfminer/ccitt.py +++ b/pdfminer/ccitt.py @@ -562,7 +562,7 @@ def main(argv): class Parser(CCITTG4Parser): def __init__(self, width, bytealign=False): - import pygame + import pygame # type: ignore CCITTG4Parser.__init__(self, width, bytealign=bytealign) self.img = pygame.Surface((self.width, 1000)) return diff --git a/pdfminer/image.py b/pdfminer/image.py index 77d14810..e825e83e 100644 --- a/pdfminer/image.py +++ b/pdfminer/image.py @@ -81,7 +81,7 @@ def export_image(self, image): if ext == '.jpg': raw_data = image.stream.get_rawdata() if LITERAL_DEVICE_CMYK in image.colorspace: - from PIL import Image + from PIL import Image # type: ignore from PIL import ImageChops ifp = BytesIO(raw_data) i = Image.open(ifp) diff --git a/setup.py b/setup.py index 941a3548..ce94b5f0 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ 'cryptography', ], extras_require={ - "dev": ["nose", "tox"], + "dev": ["nose", "tox", "mypy == 0.910"], "docs": ["sphinx", "sphinx-argparse"], }, description='PDF parser and analyzer', diff --git a/tox.ini b/tox.ini index 1908d96d..23f8f8b3 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ whitelist_externals = flake8 commands = flake8 pdfminer/ tools/ tests/ --count --statistics + mypy --install-types --non-interactive pdfminer nosetests --nologcapture python -m sphinx -b html docs/source docs/build/html python -m sphinx -b doctest docs/source docs/build/doctest