From 755915c357fc090133aeea62963216f83e135f05 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 12 Feb 2026 10:33:00 -0800 Subject: [PATCH] typing stuff --- .mypy-baseline.txt | 1 - src/documents/consumer.py | 2 +- src/documents/filters.py | 5 +++-- src/documents/views.py | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.mypy-baseline.txt b/.mypy-baseline.txt index 62dd8ac93..dcbcdbfc1 100644 --- a/.mypy-baseline.txt +++ b/.mypy-baseline.txt @@ -173,7 +173,6 @@ src/documents/filters.py:0: error: Function is missing a type annotation [no-un src/documents/filters.py:0: error: Function is missing a type annotation [no-untyped-def] src/documents/filters.py:0: error: Function is missing a type annotation [no-untyped-def] src/documents/filters.py:0: error: Function is missing a type annotation [no-untyped-def] -src/documents/filters.py:0: error: Function is missing a type annotation [no-untyped-def] src/documents/filters.py:0: error: Function is missing a type annotation for one or more arguments [no-untyped-def] src/documents/filters.py:0: error: Function is missing a type annotation for one or more arguments [no-untyped-def] src/documents/filters.py:0: error: Function is missing a type annotation for one or more arguments [no-untyped-def] diff --git a/src/documents/consumer.py b/src/documents/consumer.py index 6730a1192..41ec87f1c 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -520,7 +520,7 @@ class ConsumerPlugin( original_document.checksum = hashlib.md5( file_for_checksum.read_bytes(), ).hexdigest() - original_document.content = text + original_document.content = text or "" original_document.page_count = page_count original_document.mime_type = mime_type original_document.original_filename = self.filename diff --git a/src/documents/filters.py b/src/documents/filters.py index 4cbf78819..2f7de1cd4 100644 --- a/src/documents/filters.py +++ b/src/documents/filters.py @@ -6,6 +6,7 @@ import json import operator from contextlib import contextmanager from typing import TYPE_CHECKING +from typing import Any from django.contrib.contenttypes.models import ContentType from django.core.exceptions import FieldError @@ -161,7 +162,7 @@ class InboxFilter(Filter): @extend_schema_field(serializers.CharField) class TitleContentFilter(Filter): - def filter(self, qs, value): + def filter(self, qs: Any, value: Any) -> Any: value = value.strip() if isinstance(value, str) else value if value: try: @@ -178,7 +179,7 @@ class TitleContentFilter(Filter): @extend_schema_field(serializers.CharField) class EffectiveContentFilter(Filter): - def filter(self, qs, value): + def filter(self, qs: Any, value: Any) -> Any: value = value.strip() if isinstance(value, str) else value if not value: return qs diff --git a/src/documents/views.py b/src/documents/views.py index fd4aecacd..804fd2c45 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -884,7 +884,9 @@ class DocumentViewSet( self.perform_update(serializer) if content_updated and content_doc.id != root_doc.id: - content_doc.content = updated_content + content_doc.content = ( + str(updated_content) if updated_content is not None else "" + ) content_doc.save(update_fields=["content", "modified"]) if getattr(root_doc, "_prefetched_objects_cache", None):