Chore(mypy): Annotate None returns for typing improvements (#11213)

This commit is contained in:
Sebastian Steinbeißer
2026-02-02 17:44:12 +01:00
committed by GitHub
parent a9c0b06e28
commit 3b5ffbf9fa
113 changed files with 1598 additions and 1510 deletions

View File

@@ -120,7 +120,7 @@ class ConsumerPluginMixin:
status: ProgressStatusOptions,
message: ConsumerStatusShortMessage | str | None = None,
document_id=None,
): # pragma: no cover
) -> None: # pragma: no cover
self.status_mgr.send_progress(
status,
message,
@@ -158,7 +158,7 @@ class ConsumerPlugin(
):
logging_name = "paperless.consumer"
def run_pre_consume_script(self):
def run_pre_consume_script(self) -> None:
"""
If one is configured and exists, run the pre-consume script and
handle its output and/or errors
@@ -201,7 +201,7 @@ class ConsumerPlugin(
exception=e,
)
def run_post_consume_script(self, document: Document):
def run_post_consume_script(self, document: Document) -> None:
"""
If one is configured and exists, run the pre-consume script and
handle its output and/or errors
@@ -361,7 +361,10 @@ class ConsumerPlugin(
tempdir.cleanup()
raise
def progress_callback(current_progress, max_progress): # pragma: no cover
def progress_callback(
current_progress,
max_progress,
) -> None: # pragma: no cover
# recalculate progress to be within 20 and 80
p = int((current_progress / max_progress) * 50 + 20)
self._send_progress(p, 100, ProgressStatusOptions.WORKING)
@@ -670,7 +673,7 @@ class ConsumerPlugin(
return document
def apply_overrides(self, document):
def apply_overrides(self, document) -> None:
if self.metadata.correspondent_id:
document.correspondent = Correspondent.objects.get(
pk=self.metadata.correspondent_id,
@@ -730,7 +733,7 @@ class ConsumerPlugin(
}
CustomFieldInstance.objects.create(**args) # adds to document
def _write(self, source, target):
def _write(self, source, target) -> None:
with (
Path(source).open("rb") as read_file,
Path(target).open("wb") as write_file,
@@ -755,7 +758,7 @@ class ConsumerPreflightPlugin(
NAME: str = "ConsumerPreflightPlugin"
logging_name = "paperless.consumer"
def pre_check_file_exists(self):
def pre_check_file_exists(self) -> None:
"""
Confirm the input file still exists where it should
"""
@@ -769,7 +772,7 @@ class ConsumerPreflightPlugin(
f"Cannot consume {self.input_doc.original_file}: File not found.",
)
def pre_check_duplicate(self):
def pre_check_duplicate(self) -> None:
"""
Using the MD5 of the file, check this exact file doesn't already exist
"""
@@ -819,7 +822,7 @@ class ConsumerPreflightPlugin(
failure_msg,
)
def pre_check_directories(self):
def pre_check_directories(self) -> None:
"""
Ensure all required directories exist before attempting to use them
"""
@@ -828,7 +831,7 @@ class ConsumerPreflightPlugin(
settings.ORIGINALS_DIR.mkdir(parents=True, exist_ok=True)
settings.ARCHIVE_DIR.mkdir(parents=True, exist_ok=True)
def pre_check_asn_value(self):
def pre_check_asn_value(self) -> None:
"""
Check that if override_asn is given, it is unique and within a valid range
"""