Skip to content

Commit

Permalink
Bump required Python version to 3.8 in remaining places.
Browse files Browse the repository at this point in the history
Follow up to 38d48aa.
  • Loading branch information
felixxm committed Jun 26, 2024
1 parent 634f3a9 commit 47fbb0d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Features
Installation instructions
=========================

* Install Python 3.6 or newer.
* Install Python 3.8 or newer.
* Install pdfminer.six.

::
Expand Down
30 changes: 11 additions & 19 deletions pdfminer/pdftypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Dict,
Iterable,
Optional,
Protocol,
Union,
List,
Tuple,
Expand Down Expand Up @@ -44,26 +45,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."""

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]
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

class PDFObject(PSObject):
pass
Expand Down
2 changes: 1 addition & 1 deletion pdfminer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pdfdocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pdfpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 47fbb0d

Please sign in to comment.