Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: drop Python 3.7 support #2793

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/github-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
use-crypto-lib: ["cryptography"]
include:
- python-version: "3.7"
- python-version: "3.8"
use-crypto-lib: "pycryptodome"
- python-version: "3.7"
- python-version: "3.8"
use-crypto-lib: "none"
steps:
- name: Update APT packages
Expand All @@ -83,7 +83,7 @@ jobs:
key: cache-downloaded-files
- name: Setup Python
uses: actions/setup-python@v5
if: matrix.python-version == '3.7' || matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
if: matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
Expand All @@ -102,7 +102,7 @@ jobs:
- name: Install requirements (Python 3)
run: |
pip install -r requirements/ci.txt
if: matrix.python-version == '3.7' || matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
if: matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
- name: Install requirements (Python 3.11+)
run: |
pip install -r requirements/ci-3.11.txt
Expand Down Expand Up @@ -215,8 +215,8 @@ jobs:
- name: Check Number of Downloaded Files
run: |
downloaded_files_count=$(find \.coverage* -type f | wc -l)
if [ $downloaded_files_count -eq 9 ]; then
echo "The expected number of files (9) were downloaded."
if [ $downloaded_files_count -eq 8 ]; then
echo "The expected number of files (8) were downloaded."
else
echo "ERROR: Expected 8 files, but found $downloaded_files_count files."
exit 1
Expand Down
8 changes: 1 addition & 7 deletions pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# POSSIBILITY OF SUCH DAMAGE.

import math
import sys
from decimal import Decimal
from pathlib import Path
from typing import (
Expand All @@ -38,6 +37,7 @@
Iterable,
Iterator,
List,
Literal,
Optional,
Sequence,
Set,
Expand Down Expand Up @@ -85,12 +85,6 @@
StreamObject,
)

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


MERGE_CROP_BOX = "cropbox" # pypdf<=3.4.0 used 'trimbox'


Expand Down
8 changes: 1 addition & 7 deletions pypdf/_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

from abc import abstractmethod
from pathlib import Path
from typing import IO, Any, Dict, List, Optional, Tuple, Union

try:
# Python 3.8+: https://peps.python.org/pep-0586
from typing import Protocol
except ImportError:
from typing_extensions import Protocol # type: ignore[assignment]
from typing import IO, Any, Dict, List, Optional, Protocol, Tuple, Union

from ._utils import StrByteType, StreamType

Expand Down
8 changes: 1 addition & 7 deletions pypdf/_text_extraction/_layout_mode/_fixed_width_page.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
"""Extract PDF text preserving the layout of the source PDF"""

import sys
from itertools import groupby
from math import ceil
from pathlib import Path
from typing import Any, Dict, Iterator, List, Optional, Tuple
from typing import Any, Dict, Iterator, List, Literal, Optional, Tuple, TypedDict

from ..._utils import logger_warning
from .. import LAYOUT_NEW_BT_GROUP_SPACE_WIDTHS
from ._font import Font
from ._text_state_manager import TextStateManager
from ._text_state_params import TextStateParams

if sys.version_info >= (3, 8):
from typing import Literal, TypedDict
else:
from typing_extensions import Literal, TypedDict


class BTGroup(TypedDict):
"""
Expand Down
13 changes: 4 additions & 9 deletions pypdf/_xobj_image_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
from io import BytesIO
from typing import Any, List, Tuple, Union, cast
from typing import Any, List, Literal, Tuple, Union, cast

from ._utils import check_if_whitespace_only, logger_warning
from .constants import ColorSpaces
Expand All @@ -15,13 +15,6 @@
NullObject,
)

if sys.version_info[:2] >= (3, 8):
from typing import Literal
else:
# PEP 586 introduced typing.Literal with Python 3.8
# For older Python versions, the backport typing_extensions is necessary:
from typing_extensions import Literal

if sys.version_info[:2] >= (3, 10):
from typing import TypeAlias
else:
Expand Down Expand Up @@ -150,7 +143,9 @@ def _extended_image_frombytes(
nb_pix = size[0] * size[1]
data_length = len(data)
if data_length == 0:
raise EmptyImageDataError("Data is 0 bytes, cannot process an image from empty data.") from exc
raise EmptyImageDataError(
"Data is 0 bytes, cannot process an image from empty data."
) from exc
if data_length % nb_pix != 0:
raise exc
k = nb_pix * len(mode) / data_length
Expand Down
8 changes: 1 addition & 7 deletions pypdf/types.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
"""Helpers for working with PDF types."""

import sys
from typing import List, Union

if sys.version_info[:2] >= (3, 8):
# Python 3.8+: https://peps.python.org/pep-0586
from typing import Literal
else:
from typing_extensions import Literal
from typing import List, Literal, Union

if sys.version_info[:2] >= (3, 10):
# Python 3.10+: https://www.python.org/dev/peps/pep-0484
Expand Down
Loading