From 74b21b789530a5dd160a6207495844fcb820a78f Mon Sep 17 00:00:00 2001 From: Imran Siddique Date: Fri, 5 Jun 2026 21:54:15 -0700 Subject: [PATCH 1/3] fix: correct import order in test_tee_providers.py (I001) --- tests/unit/test_tee_providers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/test_tee_providers.py b/tests/unit/test_tee_providers.py index d9867289..4c161f35 100644 --- a/tests/unit/test_tee_providers.py +++ b/tests/unit/test_tee_providers.py @@ -2,9 +2,9 @@ from __future__ import annotations -from pathlib import Path import subprocess import sys +from pathlib import Path from unittest.mock import MagicMock, patch import pytest @@ -14,7 +14,6 @@ from cmcp_gateway.tee.tdx import TDXProvider from cmcp_gateway.tee.tpm import TPMProvider - # ── OpaqueProvider ───────────────────────────────────────────────────────────── def test_opaque_detect_returns_false() -> None: From db35e58561fbe486457ebe41b8b7f94f4e33fa9d Mon Sep 17 00:00:00 2001 From: Imran Siddique Date: Fri, 5 Jun 2026 21:58:13 -0700 Subject: [PATCH 2/3] fix: remove unused type: ignore annotations (warn_unused_ignores) --- src/cmcp_gateway/tee/sev_snp.py | 2 +- src/cmcp_gateway/tee/tdx.py | 2 +- src/cmcp_gateway/tee/tpm.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmcp_gateway/tee/sev_snp.py b/src/cmcp_gateway/tee/sev_snp.py index 44c46fb9..0c520191 100644 --- a/src/cmcp_gateway/tee/sev_snp.py +++ b/src/cmcp_gateway/tee/sev_snp.py @@ -74,7 +74,7 @@ def get_attestation_report(self, nonce: bytes) -> AttestationReport: try: with open(_SEV_GUEST_DEVICE, "rb") as fd: - fcntl.ioctl(fd, _SNP_GET_REPORT, buf) # type: ignore[attr-defined] + fcntl.ioctl(fd, _SNP_GET_REPORT, buf) except OSError as exc: raise RuntimeError(f"SEV-SNP attestation failed: {exc}") from exc diff --git a/src/cmcp_gateway/tee/tdx.py b/src/cmcp_gateway/tee/tdx.py index 863b1407..16e7f2d9 100644 --- a/src/cmcp_gateway/tee/tdx.py +++ b/src/cmcp_gateway/tee/tdx.py @@ -64,7 +64,7 @@ def get_attestation_report(self, nonce: bytes) -> AttestationReport: try: with open(_TDX_GUEST_DEVICE, "rb") as fd: - fcntl.ioctl(fd, _TDX_CMD_GET_REPORT0, buf) # type: ignore[attr-defined] + fcntl.ioctl(fd, _TDX_CMD_GET_REPORT0, buf) except OSError as exc: raise RuntimeError(f"TDX attestation failed: {exc}") from exc diff --git a/src/cmcp_gateway/tee/tpm.py b/src/cmcp_gateway/tee/tpm.py index 37a0310a..c0710edb 100644 --- a/src/cmcp_gateway/tee/tpm.py +++ b/src/cmcp_gateway/tee/tpm.py @@ -15,7 +15,7 @@ pass try: - import tpm2_pytss # type: ignore[import-not-found] + import tpm2_pytss _TSS2_AVAILABLE = True except ImportError: @@ -53,8 +53,8 @@ def get_attestation_report(self, nonce: bytes) -> AttestationReport: # ── tpm2-pytss path ─────────────────────────────────────────────────────── def _report_via_tss2(self, nonce: bytes) -> AttestationReport: - from tpm2_pytss.ESAPI import ESAPI # type: ignore[import-not-found] - from tpm2_pytss.types import ( # type: ignore[import-not-found] + from tpm2_pytss.ESAPI import ESAPI + from tpm2_pytss.types import ( TPM2_ALG, TPM2B_DATA, TPML_PCR_SELECTION, From 0fe28b660b1c308d2c0ec8cb941d94ca1584ca25 Mon Sep 17 00:00:00 2001 From: Imran Siddique Date: Fri, 5 Jun 2026 22:01:59 -0700 Subject: [PATCH 3/3] fix: add mypy overrides for linux-only TEE files; restore attr-defined ignores --- pyproject.toml | 4 ++++ src/cmcp_gateway/tee/sev_snp.py | 2 +- src/cmcp_gateway/tee/tdx.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9c1b3f4e..107bb164 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,3 +81,7 @@ strict = true ignore_missing_imports = true warn_return_any = false files = ["src/cmcp_gateway"] + +[[tool.mypy.overrides]] +module = ["cmcp_gateway.tee.sev_snp", "cmcp_gateway.tee.tdx"] +warn_unused_ignores = false diff --git a/src/cmcp_gateway/tee/sev_snp.py b/src/cmcp_gateway/tee/sev_snp.py index 0c520191..44c46fb9 100644 --- a/src/cmcp_gateway/tee/sev_snp.py +++ b/src/cmcp_gateway/tee/sev_snp.py @@ -74,7 +74,7 @@ def get_attestation_report(self, nonce: bytes) -> AttestationReport: try: with open(_SEV_GUEST_DEVICE, "rb") as fd: - fcntl.ioctl(fd, _SNP_GET_REPORT, buf) + fcntl.ioctl(fd, _SNP_GET_REPORT, buf) # type: ignore[attr-defined] except OSError as exc: raise RuntimeError(f"SEV-SNP attestation failed: {exc}") from exc diff --git a/src/cmcp_gateway/tee/tdx.py b/src/cmcp_gateway/tee/tdx.py index 16e7f2d9..863b1407 100644 --- a/src/cmcp_gateway/tee/tdx.py +++ b/src/cmcp_gateway/tee/tdx.py @@ -64,7 +64,7 @@ def get_attestation_report(self, nonce: bytes) -> AttestationReport: try: with open(_TDX_GUEST_DEVICE, "rb") as fd: - fcntl.ioctl(fd, _TDX_CMD_GET_REPORT0, buf) + fcntl.ioctl(fd, _TDX_CMD_GET_REPORT0, buf) # type: ignore[attr-defined] except OSError as exc: raise RuntimeError(f"TDX attestation failed: {exc}") from exc