Use Python 3.9-style type hinting for tuple[] and AbstractSet -> Set

This commit is contained in:
James R. Barlow
2023-10-01 00:09:05 -07:00
parent 113a6b45bd
commit f4c211fa2d
3 changed files with 10 additions and 10 deletions
+6 -6
View File
@@ -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.