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

This commit is contained in:
Sebastian Steinbeißer
2026-02-02 08:44:12 -08:00
committed by GitHub
parent a9c0b06e28
commit 3b5ffbf9fa
113 changed files with 1598 additions and 1510 deletions
+21 -21
View File
@@ -22,7 +22,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
user = User.objects.create_superuser(username="temp_admin")
self.client.force_authenticate(user=user)
def test_api_get_config(self):
def test_api_get_config(self) -> None:
"""
GIVEN:
- API request to get app config
@@ -78,7 +78,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
},
)
def test_api_get_ui_settings_with_config(self):
def test_api_get_ui_settings_with_config(self) -> None:
"""
GIVEN:
- Existing config with app_title, app_logo specified
@@ -101,7 +101,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
| response.data["settings"],
)
def test_api_update_config(self):
def test_api_update_config(self) -> None:
"""
GIVEN:
- API request to update app config
@@ -124,7 +124,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
config = ApplicationConfiguration.objects.first()
self.assertEqual(config.color_conversion_strategy, ColorConvertChoices.RGB)
def test_api_update_config_empty_fields(self):
def test_api_update_config_empty_fields(self) -> None:
"""
GIVEN:
- API request to update app config with empty string for user_args JSONField and language field
@@ -151,7 +151,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertEqual(config.language, None)
self.assertEqual(config.barcode_tag_mapping, None)
def test_api_replace_app_logo(self):
def test_api_replace_app_logo(self) -> None:
"""
GIVEN:
- Existing config with app_logo specified
@@ -200,7 +200,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
)
self.assertFalse(Path(old_logo.path).exists())
def test_api_rejects_malicious_svg_logo(self):
def test_api_rejects_malicious_svg_logo(self) -> None:
"""
GIVEN:
- An SVG logo containing a <script> tag
@@ -227,7 +227,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn("disallowed svg tag", str(response.data).lower())
def test_api_rejects_malicious_svg_with_style_javascript(self):
def test_api_rejects_malicious_svg_with_style_javascript(self) -> None:
"""
GIVEN:
- An SVG logo containing javascript: in style attribute
@@ -257,7 +257,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
)
self.assertIn("style", str(response.data).lower())
def test_api_rejects_svg_with_style_expression(self):
def test_api_rejects_svg_with_style_expression(self) -> None:
"""
GIVEN:
- An SVG logo containing CSS expression() in style
@@ -283,7 +283,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn("disallowed", str(response.data).lower())
def test_api_rejects_svg_with_style_cdata_javascript(self):
def test_api_rejects_svg_with_style_cdata_javascript(self) -> None:
"""
GIVEN:
- An SVG logo with javascript: hidden in a CDATA style block
@@ -312,7 +312,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn("disallowed", str(response.data).lower())
def test_api_rejects_svg_with_style_import(self):
def test_api_rejects_svg_with_style_import(self) -> None:
"""
GIVEN:
- An SVG logo containing @import in style
@@ -338,7 +338,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn("disallowed", str(response.data).lower())
def test_api_accepts_valid_svg_with_safe_style(self):
def test_api_accepts_valid_svg_with_safe_style(self) -> None:
"""
GIVEN:
- A valid SVG logo with safe style attributes
@@ -364,7 +364,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_api_accepts_valid_svg_with_safe_style_tag(self):
def test_api_accepts_valid_svg_with_safe_style_tag(self) -> None:
"""
GIVEN:
- A valid SVG logo with an embedded <style> tag
@@ -394,7 +394,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_api_rejects_svg_with_disallowed_attribute(self):
def test_api_rejects_svg_with_disallowed_attribute(self) -> None:
"""
GIVEN:
- An SVG with a disallowed attribute (onclick)
@@ -421,7 +421,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertIn("disallowed", str(response.data).lower())
self.assertIn("attribute", str(response.data).lower())
def test_api_rejects_svg_with_disallowed_tag(self):
def test_api_rejects_svg_with_disallowed_tag(self) -> None:
"""
GIVEN:
- An SVG with a disallowed tag (script)
@@ -449,7 +449,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertIn("disallowed", str(response.data).lower())
self.assertIn("tag", str(response.data).lower())
def test_api_rejects_svg_with_javascript_href(self):
def test_api_rejects_svg_with_javascript_href(self) -> None:
"""
GIVEN:
- An SVG with javascript: in href attribute
@@ -478,7 +478,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertIn("disallowed", str(response.data).lower())
self.assertIn("javascript", str(response.data).lower())
def test_api_rejects_svg_with_javascript_xlink_href(self):
def test_api_rejects_svg_with_javascript_xlink_href(self) -> None:
"""
GIVEN:
- An SVG with javascript: in xlink:href attribute
@@ -504,7 +504,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertIn("disallowed", str(response.data).lower())
self.assertIn("javascript", str(response.data).lower())
def test_api_rejects_svg_with_data_text_html_href(self):
def test_api_rejects_svg_with_data_text_html_href(self) -> None:
"""
GIVEN:
- An SVG with data:text/html in href attribute
@@ -533,7 +533,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
# This will now catch "Disallowed URI scheme"
self.assertIn("disallowed", str(response.data).lower())
def test_api_rejects_svg_with_unknown_namespace_attribute(self):
def test_api_rejects_svg_with_unknown_namespace_attribute(self) -> None:
"""
GIVEN:
- An SVG with an attribute in an unknown/custom namespace
@@ -599,7 +599,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
# Check for the error message raised by the safe_prefixes check
self.assertIn("uri scheme not allowed", str(response.data).lower())
def test_create_not_allowed(self):
def test_create_not_allowed(self) -> None:
"""
GIVEN:
- API request to create a new app config
@@ -621,7 +621,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
self.assertEqual(ApplicationConfiguration.objects.count(), 1)
def test_update_llm_api_key(self):
def test_update_llm_api_key(self) -> None:
"""
GIVEN:
- Existing config with llm_api_key specified
@@ -663,7 +663,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
config.refresh_from_db()
self.assertEqual(config.llm_api_key, None)
def test_enable_ai_index_triggers_update(self):
def test_enable_ai_index_triggers_update(self) -> None:
"""
GIVEN:
- Existing config with AI disabled