From 64ee887669c6db44dae49eca29b4e8aa7e1c6adf Mon Sep 17 00:00:00 2001 From: Kdairatchi <96064915+kdairatchi@users.noreply.github.com> Date: Tue, 17 Mar 2026 20:21:44 -0400 Subject: [PATCH] python: make StrEnum shim mypy-safe on 3.10 --- .github/workflows/ci.yml | 3 ++- python/src/roar_sdk/_compat.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f9fac5..35f9682 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,7 +65,8 @@ jobs: - name: typecheck — mypy run: mypy src/roar_sdk/ --ignore-missing-imports working-directory: python - - run: pytest tests/conformance/ -v + - name: conformance tests + run: pytest tests/test_conformance*.py -v working-directory: . - name: cross-SDK interop tests run: pytest tests/test_cross_sdk_interop.py -v diff --git a/python/src/roar_sdk/_compat.py b/python/src/roar_sdk/_compat.py index d987f74..e10a030 100644 --- a/python/src/roar_sdk/_compat.py +++ b/python/src/roar_sdk/_compat.py @@ -1,11 +1,10 @@ -# Python 3.10 compatibility shim for StrEnum (added in 3.11) -try: - from enum import StrEnum -except ImportError: - from enum import Enum +"""Compatibility helpers for Python version differences.""" - class StrEnum(str, Enum): # type: ignore[no-redef] - """Backport of Python 3.11 StrEnum for Python 3.10.""" +from enum import Enum - def __str__(self) -> str: - return self.value + +class StrEnum(str, Enum): + """Lightweight StrEnum backport for consistent typing on Python 3.10+.""" + + def __str__(self) -> str: + return self.value