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

This commit is contained in:
Sebastian Steinbeißer authored and GitHub committed 2026-02-02 08:44:12 -08:00
1 parent a9c0b06e28
commit 3b5ffbf9fa
113 files changed
+1598 -1510

No files matched your search

+18 -18
View File
@@ -58,7 +58,7 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
archive_filename="0000001.pdf",
)
def assertSanityError(self, doc: Document, messageRegex):
def assertSanityError(self, doc: Document, messageRegex) -> None:
messages = check_sanity()
self.assertTrue(messages.has_error)
with self.assertLogs() as capture:
@@ -69,7 +69,7 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
)
self.assertRegex(capture.records[1].message, messageRegex)
def test_no_issues(self):
def test_no_issues(self) -> None:
self.make_test_data()
messages = check_sanity()
self.assertFalse(messages.has_error)
@@ -83,59 +83,59 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
"Sanity checker detected no issues.",
)
def test_no_docs(self):
def test_no_docs(self) -> None:
self.assertEqual(len(check_sanity()), 0)
def test_success(self):
def test_success(self) -> None:
self.make_test_data()
self.assertEqual(len(check_sanity()), 0)
def test_no_thumbnail(self):
def test_no_thumbnail(self) -> None:
doc = self.make_test_data()
Path(doc.thumbnail_path).unlink()
self.assertSanityError(doc, "Thumbnail of document does not exist")
def test_thumbnail_no_access(self):
def test_thumbnail_no_access(self) -> None:
doc = self.make_test_data()
Path(doc.thumbnail_path).chmod(0o000)
self.assertSanityError(doc, "Cannot read thumbnail file of document")
Path(doc.thumbnail_path).chmod(0o777)
def test_no_original(self):
def test_no_original(self) -> None:
doc = self.make_test_data()
Path(doc.source_path).unlink()
self.assertSanityError(doc, "Original of document does not exist.")
def test_original_no_access(self):
def test_original_no_access(self) -> None:
doc = self.make_test_data()
Path(doc.source_path).chmod(0o000)
self.assertSanityError(doc, "Cannot read original file of document")
Path(doc.source_path).chmod(0o777)
def test_original_checksum_mismatch(self):
def test_original_checksum_mismatch(self) -> None:
doc = self.make_test_data()
doc.checksum = "WOW"
doc.save()
self.assertSanityError(doc, "Checksum mismatch. Stored: WOW, actual: ")
def test_no_archive(self):
def test_no_archive(self) -> None:
doc = self.make_test_data()
Path(doc.archive_path).unlink()
self.assertSanityError(doc, "Archived version of document does not exist.")
def test_archive_no_access(self):
def test_archive_no_access(self) -> None:
doc = self.make_test_data()
Path(doc.archive_path).chmod(0o000)
self.assertSanityError(doc, "Cannot read archive file of document")
Path(doc.archive_path).chmod(0o777)
def test_archive_checksum_mismatch(self):
def test_archive_checksum_mismatch(self) -> None:
doc = self.make_test_data()
doc.archive_checksum = "WOW"
doc.save()
self.assertSanityError(doc, "Checksum mismatch of archived document")
def test_empty_content(self):
def test_empty_content(self) -> None:
doc = self.make_test_data()
doc.content = ""
doc.save()
@@ -148,7 +148,7 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
"Document contains no OCR data",
)
def test_orphaned_file(self):
def test_orphaned_file(self) -> None:
self.make_test_data()
Path(self.dirs.originals_dir, "orphaned").touch()
messages = check_sanity()
@@ -161,7 +161,7 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
@override_settings(
APP_LOGO="logo/logo.png",
)
def test_ignore_logo(self):
def test_ignore_logo(self) -> None:
self.make_test_data()
logo_dir = Path(self.dirs.media_dir, "logo")
logo_dir.mkdir(parents=True, exist_ok=True)
@@ -169,20 +169,20 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
messages = check_sanity()
self.assertFalse(messages.has_warning)
def test_ignore_ignorable_files(self):
def test_ignore_ignorable_files(self) -> None:
self.make_test_data()
Path(self.dirs.media_dir, ".DS_Store").touch()
Path(self.dirs.media_dir, "desktop.ini").touch()
messages = check_sanity()
self.assertFalse(messages.has_warning)
def test_archive_filename_no_checksum(self):
def test_archive_filename_no_checksum(self) -> None:
doc = self.make_test_data()
doc.archive_checksum = None
doc.save()
self.assertSanityError(doc, "has an archive file, but its checksum is missing.")
def test_archive_checksum_no_filename(self):
def test_archive_checksum_no_filename(self) -> None:
doc = self.make_test_data()
doc.archive_filename = None
doc.save()