From 415de77457139d54b5bdec839f3a4cf708c7ef34 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 19 Nov 2023 23:51:27 -0800 Subject: [PATCH] imageops: fix annots since not using singledispatch anymore --- src/ocrmypdf/imageops.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/ocrmypdf/imageops.py b/src/ocrmypdf/imageops.py index adc0d690..faa913bf 100644 --- a/src/ocrmypdf/imageops.py +++ b/src/ocrmypdf/imageops.py @@ -7,17 +7,9 @@ from __future__ import annotations import logging from math import floor, sqrt -from typing import Optional from PIL import Image -# While from __future__ import annotations, we use singledispatch here, which -# does not support annotations. Disable check about using old-style typing -# until Python 3.10, OR when drop singledispatch in ocrmypdf 15. -# ruff: noqa: UP006 -# ruff: noqa: UP007 - - log = logging.getLogger(__name__) @@ -38,9 +30,9 @@ def _calculate_downsample( image_size: tuple[int, int], bytes_per_pixel: int, *, - max_size: Optional[tuple[int, int]] = None, - max_pixels: Optional[int] = None, - max_bytes: Optional[int] = None, + max_size: tuple[int, int] | None = None, + max_pixels: int | None = None, + max_bytes: int | None = None, ) -> tuple[int, int]: """Calculate image size required to downsample an image to fit limits. @@ -98,9 +90,9 @@ def _calculate_downsample( def calculate_downsample( image: Image.Image, *, - max_size: Optional[tuple[int, int]] = None, - max_pixels: Optional[int] = None, - max_bytes: Optional[int] = None, + max_size: tuple[int, int] | None = None, + max_pixels: int | None = None, + max_bytes: int | None = None, ) -> tuple[int, int]: """Calculate image size required to downsample an image to fit limits.