mirror of
https://github.com/ocrmypdf/OCRmyPDF.git
synced 2026-05-19 03:58:06 -04:00
Use Python 3.9-style type hinting for tuple[] and AbstractSet -> Set
This commit is contained in:
@@ -210,7 +210,7 @@ def create_options(
|
||||
return options
|
||||
|
||||
|
||||
def ocr( # noqa: ruff: disable=D417
|
||||
def ocr( # noqa: D417
|
||||
input_file: PathOrIO,
|
||||
output_file: PathOrIO,
|
||||
*,
|
||||
|
||||
@@ -7,7 +7,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from math import floor, sqrt
|
||||
from typing import Optional, Tuple
|
||||
from typing import Optional
|
||||
|
||||
from PIL import Image
|
||||
|
||||
@@ -43,13 +43,13 @@ def bytes_per_pixel(mode: str) -> int:
|
||||
|
||||
|
||||
def _calculate_downsample(
|
||||
image_size: Tuple[int, int],
|
||||
image_size: tuple[int, int],
|
||||
bytes_per_pixel: int,
|
||||
*,
|
||||
max_size: Optional[Tuple[int, int]] = None,
|
||||
max_size: Optional[tuple[int, int]] = None,
|
||||
max_pixels: Optional[int] = None,
|
||||
max_bytes: Optional[int] = None,
|
||||
) -> Tuple[int, int]:
|
||||
) -> tuple[int, int]:
|
||||
"""Calculate image size required to downsample an image to fit limits.
|
||||
|
||||
If no limit is exceeded, the input image's size is returned.
|
||||
@@ -106,10 +106,10 @@ def _calculate_downsample(
|
||||
def calculate_downsample(
|
||||
image: Image.Image,
|
||||
*,
|
||||
max_size: Optional[Tuple[int, int]] = None,
|
||||
max_size: Optional[tuple[int, int]] = None,
|
||||
max_pixels: Optional[int] = None,
|
||||
max_bytes: Optional[int] = None,
|
||||
) -> Tuple[int, int]:
|
||||
) -> tuple[int, int]:
|
||||
"""Calculate image size required to downsample an image to fit limits.
|
||||
|
||||
If no limit is exceeded, the input image's size is returned.
|
||||
|
||||
@@ -7,10 +7,10 @@ from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from argparse import ArgumentParser, Namespace
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Sequence, Set
|
||||
from logging import Handler
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, AbstractSet, NamedTuple
|
||||
from typing import TYPE_CHECKING, NamedTuple
|
||||
|
||||
import pluggy
|
||||
|
||||
@@ -406,7 +406,7 @@ class OcrEngine(ABC):
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def languages(options: Namespace) -> AbstractSet[str]:
|
||||
def languages(options: Namespace) -> Set[str]:
|
||||
"""Returns the set of all languages that are supported by the engine.
|
||||
|
||||
Languages are typically given in 3-letter ISO 3166-1 codes, but actually
|
||||
|
||||
Reference in New Issue
Block a user