Chore: Drop Python 3.9 support (#7774)

This commit is contained in:
Trenton H
2024-09-26 12:22:24 -07:00
committed by GitHub
parent 5e687d9a93
commit e6f59472e4
44 changed files with 970 additions and 1066 deletions

View File

@@ -3,7 +3,6 @@ import re
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Optional
from django.conf import settings
from PIL import Image
@@ -124,7 +123,7 @@ class RasterisedDocumentParser(DocumentParser):
)
return no_alpha_image
def get_dpi(self, image) -> Optional[int]:
def get_dpi(self, image) -> int | None:
try:
with Image.open(image) as im:
x, y = im.info["dpi"]
@@ -133,7 +132,7 @@ class RasterisedDocumentParser(DocumentParser):
self.log.warning(f"Error while getting DPI from image {image}: {e}")
return None
def calculate_a4_dpi(self, image) -> Optional[int]:
def calculate_a4_dpi(self, image) -> int | None:
try:
with Image.open(image) as im:
width, height = im.size
@@ -148,9 +147,9 @@ class RasterisedDocumentParser(DocumentParser):
def extract_text(
self,
sidecar_file: Optional[Path],
sidecar_file: Path | None,
pdf_file: Path,
) -> Optional[str]:
) -> str | None:
# When re-doing OCR, the sidecar contains ONLY the new text, not
# the whole text, so do not utilize it in that case
if (