From 3d79e66d82cef295b2bf939895f7cf8b08551dc6 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 26 Jun 2024 11:11:32 +0200 Subject: [PATCH 1/3] Bump required Python version to 3.8 in remaining places. Follow up to 38d48aa546d60ed951e096decc2357ce8d5983dd. --- CONTRIBUTING.md | 2 +- docs/source/index.rst | 2 +- pdfminer/pdftypes.py | 30 +++++++++++------------------- pdfminer/utils.py | 2 +- setup.py | 4 +--- tests/test_pdfdocument.py | 2 +- tests/test_pdfpage.py | 2 +- tests/test_utils.py | 2 +- 8 files changed, 18 insertions(+), 28 deletions(-) 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" From 70ead4f34469f160d3e158b6dee49e687ea7ac27 Mon Sep 17 00:00:00 2001 From: Pieter Marsman Date: Sat, 6 Jul 2024 15:41:55 +0200 Subject: [PATCH 2/3] Remove Protocol import --- pdfminer/pdftypes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pdfminer/pdftypes.py b/pdfminer/pdftypes.py index c459a43e..1fb5be38 100644 --- a/pdfminer/pdftypes.py +++ b/pdfminer/pdftypes.py @@ -1,7 +1,6 @@ import io import logging import zlib -from typing import Protocol from typing import ( TYPE_CHECKING, Any, From a191c5e17d87f4671386166a1eb0312c38720a60 Mon Sep 17 00:00:00 2001 From: Pieter Marsman Date: Sat, 6 Jul 2024 15:43:25 +0200 Subject: [PATCH 3/3] Added CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad4282d5..a7c7198d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Updated Python 3.7 syntax to 3.8 ([#956](https://github.com/pdfminer/pdfminer.six/pull/956)) +- Updated all Python version specifications to a minimum of 3.8 ([#969](https://github.com/pdfminer/pdfminer.six/pull/969)) ## [20231228]