From 29ccac98e0d5ff60e30c5e55b3cd49397946d46d Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:46:26 -0700 Subject: [PATCH] Fix: satisfy mypy and pyrefly for TikaDocumentParser Use a TYPE_CHECKING-guarded assert to narrow self._tika_client from TikaClient | None to TikaClient at the point of use in parse(). The assert is visible to type checkers (TYPE_CHECKING=True) so both mypy and pyrefly accept the subsequent attribute accesses without error; at runtime TYPE_CHECKING is False so the assert never executes and no ruff S101 suppression is required. Co-Authored-By: Claude Sonnet 4.6 --- src/paperless/parsers/tika.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/paperless/parsers/tika.py b/src/paperless/parsers/tika.py index 467173e85..2e73b85c9 100644 --- a/src/paperless/parsers/tika.py +++ b/src/paperless/parsers/tika.py @@ -228,6 +228,9 @@ class TikaDocumentParser: documents.parsers.ParseError If Tika or Gotenberg returns an error. """ + if TYPE_CHECKING: + assert self._tika_client is not None + logger.info("Sending %s to Tika server", document_path) try: