From d35b0bc78c7ed007864181abd73f3b407559cdfa Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Thu, 9 Apr 2026 20:04:16 +0200 Subject: [PATCH] chore: mypy fixes for routes.py + legal_document_service + control_export_service - Add [mypy-compliance.api.routes] to mypy.ini strict scope - Fix bare `dict` type annotation in routes.py update_requirement handler - Fix Column[str] return type in control_export_service.download_file - Fix unused type:ignore in legal_document_service.upload_word - Add union-attr ignore for optional requirement null access in routes.py mypy compliance/ -> Success on 149 source files 173/173 pytest pass Co-Authored-By: Claude Opus 4.6 (1M context) --- backend-compliance/compliance/api/routes.py | 4 ++-- .../compliance/services/control_export_service.py | 2 +- .../compliance/services/legal_document_service.py | 2 +- backend-compliance/mypy.ini | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend-compliance/compliance/api/routes.py b/backend-compliance/compliance/api/routes.py index 900b93f..bd19755 100644 --- a/backend-compliance/compliance/api/routes.py +++ b/backend-compliance/compliance/api/routes.py @@ -167,7 +167,7 @@ async def get_requirement( rag = get_rag_client() assistant = AIComplianceAssistant() query = ( - f"{requirement.title} {requirement.article or ''}" + f"{requirement.title} {requirement.article or ''}" # type: ignore[union-attr] ) collection = assistant._collection_for_regulation( regulation.code if regulation else "" @@ -250,7 +250,7 @@ async def delete_requirement( @router.put("/requirements/{requirement_id}") async def update_requirement( requirement_id: str, - updates: dict, + updates: dict[str, Any], svc: RegulationRequirementService = Depends(get_reg_req_service), ) -> dict[str, Any]: """Update a requirement with implementation/audit details.""" diff --git a/backend-compliance/compliance/services/control_export_service.py b/backend-compliance/compliance/services/control_export_service.py index 7294d76..dec4c41 100644 --- a/backend-compliance/compliance/services/control_export_service.py +++ b/backend-compliance/compliance/services/control_export_service.py @@ -317,7 +317,7 @@ class ControlExportService: if not export.file_path or not os.path.exists(export.file_path): raise NotFoundError("Export file not found") - return export.file_path + return str(export.file_path) def list_exports( self, limit: int, offset: int diff --git a/backend-compliance/compliance/services/legal_document_service.py b/backend-compliance/compliance/services/legal_document_service.py index 02f8ad8..b6ff55e 100644 --- a/backend-compliance/compliance/services/legal_document_service.py +++ b/backend-compliance/compliance/services/legal_document_service.py @@ -248,7 +248,7 @@ class LegalDocumentService: html_content = "" try: - import mammoth # type: ignore + import mammoth # noqa: F811 result = mammoth.convert_to_html(io.BytesIO(content_bytes)) html_content = result.value except ImportError: diff --git a/backend-compliance/mypy.ini b/backend-compliance/mypy.ini index 8425039..9eda9ef 100644 --- a/backend-compliance/mypy.ini +++ b/backend-compliance/mypy.ini @@ -97,5 +97,7 @@ ignore_errors = False ignore_errors = False [mypy-compliance.api.dsfa_routes] ignore_errors = False +[mypy-compliance.api.routes] +ignore_errors = False [mypy-compliance.api._http_errors] ignore_errors = False