diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index daa600c1..898a26fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,7 @@ Any contribution is appreciated! You might want to: * Pull requests should be merged to master. * Include unit tests when possible. In case of bugs, this will help to prevent the same mistake in the future. In case of features, this will show that your code works correctly. -* Code should work for Python 3.6+. +* Code should work for Python 3.8+. * Test your code by using nox (see below). * New features should be well documented using docstrings. * Check if the [README.md](../README.md) or [readthedocs](../docs/source) documentation needs to be updated. diff --git a/docs/source/index.rst b/docs/source/index.rst index 8650b5d5..5b1a2bf4 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -59,7 +59,7 @@ Features Installation instructions ========================= -* Install Python 3.6 or newer. +* Install Python 3.8 or newer. * Install pdfminer.six. :: diff --git a/pdfminer/pdftypes.py b/pdfminer/pdftypes.py index 5f302ba3..03f6941b 100644 --- a/pdfminer/pdftypes.py +++ b/pdfminer/pdftypes.py @@ -1,6 +1,5 @@ import io import logging -import sys import zlib from typing import ( TYPE_CHECKING, @@ -8,6 +7,7 @@ Dict, Iterable, Optional, + Protocol, Union, List, Tuple, @@ -44,25 +44,17 @@ LITERALS_JPX_DECODE = (LIT("JPXDecode"),) -if sys.version_info >= (3, 8): - from typing import Protocol +class DecipherCallable(Protocol): + """Fully typed a decipher callback, with optional parameter.""" - class DecipherCallable(Protocol): - """Fully typed a decipher callback, with optional parameter.""" - - def __call__( - self, - objid: int, - genno: int, - data: bytes, - attrs: Optional[Dict[str, Any]] = None, - ) -> bytes: - raise NotImplementedError - -else: # Fallback for older Python - from typing import Callable - - DecipherCallable = Callable[..., bytes] + def __call__( + self, + objid: int, + genno: int, + data: bytes, + attrs: Optional[Dict[str, Any]] = None, + ) -> bytes: + raise NotImplementedError class PDFObject(PSObject): diff --git a/pdfminer/utils.py b/pdfminer/utils.py index 0afdcdf1..52080654 100644 --- a/pdfminer/utils.py +++ b/pdfminer/utils.py @@ -39,7 +39,7 @@ AnyIO = Union[TextIO, BinaryIO] -class open_filename(object): +class open_filename: """ Context manager that allows opening a filename (str or pathlib.PurePath type is supported) and closes it on exit, diff --git a/setup.py b/setup.py index 84e5ceea..1dc197d5 100644 --- a/setup.py +++ b/setup.py @@ -16,8 +16,6 @@ install_requires=[ "charset-normalizer >= 2.0.0", "cryptography >= 36.0.0", - 'typing_extensions; python_version < "3.8"', - 'importlib_metadata; python_version < "3.8"', ], extras_require={ "dev": ["pytest", "nox", "black", "mypy == 0.931"], @@ -41,7 +39,7 @@ "layout analysis", "text mining", ], - python_requires=">=3.6", + python_requires=">=3.8", classifiers=[ "Programming Language :: Python", "Programming Language :: Python :: 3.8", diff --git a/tests/test_pdfdocument.py b/tests/test_pdfdocument.py index c57126fb..343e1dcb 100644 --- a/tests/test_pdfdocument.py +++ b/tests/test_pdfdocument.py @@ -8,7 +8,7 @@ from tests.helpers import absolute_sample_path -class TestPdfDocument(object): +class TestPdfDocument: def test_get_zero_objid_raises_pdfobjectnotfound(self): with open(absolute_sample_path("simple1.pdf"), "rb") as in_file: parser = PDFParser(in_file) diff --git a/tests/test_pdfpage.py b/tests/test_pdfpage.py index c3fe86c2..a99a2f47 100644 --- a/tests/test_pdfpage.py +++ b/tests/test_pdfpage.py @@ -4,7 +4,7 @@ from tests.helpers import absolute_sample_path -class TestPdfPage(object): +class TestPdfPage: def test_page_labels(self): path = absolute_sample_path("contrib/pagelabels.pdf") expected_labels = ["iii", "iv", "1", "2", "1"] diff --git a/tests/test_utils.py b/tests/test_utils.py index 160b02b4..af37ce9a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -71,7 +71,7 @@ def given_plane_with_one_object(object_size=50, gridsize=50): return plane, obj -class TestFunctions(object): +class TestFunctions: def test_shorten_str(self): s = shorten_str("Hello there World", 15) assert s == "Hello ... World"