From d37aae3f698f25a55a692ed77613b8e924073db3 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 16 Sep 2024 22:32:11 +0000 Subject: [PATCH] iterating --- python-spec/src/somacore/types.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python-spec/src/somacore/types.py b/python-spec/src/somacore/types.py index 7c152a0..12febe1 100644 --- a/python-spec/src/somacore/types.py +++ b/python-spec/src/somacore/types.py @@ -8,8 +8,6 @@ import sys from concurrent import futures from typing import TYPE_CHECKING, Any, NoReturn, Optional, Sequence, Type, TypeVar -from types import get_original_bases # only exists in Python 3.12 and above - from typing_extensions import Protocol, TypeGuard @@ -58,9 +56,15 @@ def stop(self) -> Optional[_T_co]: ... @property def step(self) -> Optional[_T_co]: ... - @property - def __orig_bases__(self) -> Any: - return get_original_bases(_T_co) + if sys.version_info >= (3, 12): + + @property + def __orig_bases__(self) -> Any: + # Only exists in Python 3.12 and above + from types import get_original_bases + + return get_original_bases(int) + # return get_original_bases(_T_co) if sys.version_info < (3, 10) and not TYPE_CHECKING: # Python 3.9 and below have a bug where any Protocol with an @property