Chore: Reduce imports for a slight memory improvement (#9217)

This commit is contained in:
Trenton H
2025-02-24 15:06:14 -08:00
committed by GitHub
parent 3104417076
commit 827fcba277
12 changed files with 71 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
import datetime
from __future__ import annotations
import logging
import mimetypes
import os
@@ -6,10 +7,10 @@ import re
import shutil
import subprocess
import tempfile
from collections.abc import Iterator
from functools import lru_cache
from pathlib import Path
from re import Match
from typing import TYPE_CHECKING
from django.conf import settings
from django.utils import timezone
@@ -19,6 +20,10 @@ from documents.signals import document_consumer_declaration
from documents.utils import copy_file_with_basic_stats
from documents.utils import run_subprocess
if TYPE_CHECKING:
import datetime
from collections.abc import Iterator
# This regular expression will try to find dates in the document at
# hand and will match the following formats:
# - XX.YY.ZZZZ with XX + YY being 1 or 2 and ZZZZ being 2 or 4 digits
@@ -106,7 +111,7 @@ def get_supported_file_extensions() -> set[str]:
return extensions
def get_parser_class_for_mime_type(mime_type: str) -> type["DocumentParser"] | None:
def get_parser_class_for_mime_type(mime_type: str) -> type[DocumentParser] | None:
"""
Returns the best parser (by weight) for the given mimetype or
None if no parser exists