mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Chore: Drop Python 3.9 support (#7774)
This commit is contained in:
@@ -10,8 +10,6 @@ from datetime import timedelta
|
||||
from fnmatch import fnmatch
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
import magic
|
||||
import pathvalidate
|
||||
@@ -84,7 +82,7 @@ class BaseMailAction:
|
||||
read mails when the action is to mark mails as read).
|
||||
"""
|
||||
|
||||
def get_criteria(self) -> Union[dict, LogicOperator]:
|
||||
def get_criteria(self) -> dict | LogicOperator:
|
||||
"""
|
||||
Returns filtering criteria/query for this mail action.
|
||||
"""
|
||||
@@ -453,7 +451,7 @@ class MailAccountHandler(LoggingMixin):
|
||||
else:
|
||||
self.log.debug(f"Skipping mail preprocessor {preprocessor_type.NAME}")
|
||||
|
||||
def _correspondent_from_name(self, name: str) -> Optional[Correspondent]:
|
||||
def _correspondent_from_name(self, name: str) -> Correspondent | None:
|
||||
try:
|
||||
return Correspondent.objects.get_or_create(name=name)[0]
|
||||
except DatabaseError as e:
|
||||
@@ -465,7 +463,7 @@ class MailAccountHandler(LoggingMixin):
|
||||
message: MailMessage,
|
||||
att: MailAttachment,
|
||||
rule: MailRule,
|
||||
) -> Optional[str]:
|
||||
) -> str | None:
|
||||
if rule.assign_title_from == MailRule.TitleSource.FROM_SUBJECT:
|
||||
return message.subject
|
||||
|
||||
@@ -484,7 +482,7 @@ class MailAccountHandler(LoggingMixin):
|
||||
self,
|
||||
message: MailMessage,
|
||||
rule: MailRule,
|
||||
) -> Optional[Correspondent]:
|
||||
) -> Correspondent | None:
|
||||
c_from = rule.assign_correspondent_from
|
||||
|
||||
if c_from == MailRule.CorrespondentSource.FROM_NOTHING:
|
||||
@@ -688,7 +686,7 @@ class MailAccountHandler(LoggingMixin):
|
||||
|
||||
def filename_inclusion_matches(
|
||||
self,
|
||||
filter_attachment_filename_include: Optional[str],
|
||||
filter_attachment_filename_include: str | None,
|
||||
filename: str,
|
||||
) -> bool:
|
||||
if filter_attachment_filename_include:
|
||||
@@ -707,7 +705,7 @@ class MailAccountHandler(LoggingMixin):
|
||||
|
||||
def filename_exclusion_matches(
|
||||
self,
|
||||
filter_attachment_filename_exclude: Optional[str],
|
||||
filter_attachment_filename_exclude: str | None,
|
||||
filename: str,
|
||||
) -> bool:
|
||||
if filter_attachment_filename_exclude:
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import re
|
||||
from html import escape
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from bleach import clean
|
||||
from bleach import linkify
|
||||
@@ -33,7 +32,7 @@ class MailDocumentParser(DocumentParser):
|
||||
|
||||
logging_name = "paperless.parsing.mail"
|
||||
|
||||
def _settings_to_gotenberg_pdfa(self) -> Optional[PdfAFormat]:
|
||||
def _settings_to_gotenberg_pdfa(self) -> PdfAFormat | None:
|
||||
"""
|
||||
Converts our requested PDF/A output into the Gotenberg API
|
||||
format
|
||||
@@ -44,7 +43,7 @@ class MailDocumentParser(DocumentParser):
|
||||
}:
|
||||
return PdfAFormat.A2b
|
||||
elif settings.OCR_OUTPUT_TYPE == OutputTypeChoices.PDF_A1: # pragma: no cover
|
||||
self.log.warn(
|
||||
self.log.warning(
|
||||
"Gotenberg does not support PDF/A-1a, choosing PDF/A-2b instead",
|
||||
)
|
||||
return PdfAFormat.A2b
|
||||
|
@@ -4,8 +4,6 @@ import random
|
||||
import uuid
|
||||
from collections import namedtuple
|
||||
from contextlib import AbstractContextManager
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@@ -199,11 +197,11 @@ class MessageBuilder:
|
||||
|
||||
def create_message(
|
||||
self,
|
||||
attachments: Union[int, list[_AttachmentDef]] = 1,
|
||||
attachments: int | list[_AttachmentDef] = 1,
|
||||
body: str = "",
|
||||
subject: str = "the subject",
|
||||
from_: str = "no_one@mail.com",
|
||||
to: Optional[list[str]] = None,
|
||||
to: list[str] | None = None,
|
||||
seen: bool = False,
|
||||
flagged: bool = False,
|
||||
processed: bool = False,
|
||||
@@ -622,8 +620,8 @@ class TestMail(
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class FilterTestCase:
|
||||
name: str
|
||||
include_pattern: Optional[str]
|
||||
exclude_pattern: Optional[str]
|
||||
include_pattern: str | None
|
||||
exclude_pattern: str | None
|
||||
expected_matches: list[str]
|
||||
|
||||
tests = [
|
||||
|
Reference in New Issue
Block a user