From c71fcf27bdca8458670b064a55cfc92fbd06b182 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 16 Sep 2024 22:35:42 +0000 Subject: [PATCH] iterating --- python-spec/src/somacore/options.py | 2 +- python-spec/src/somacore/types.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/python-spec/src/somacore/options.py b/python-spec/src/somacore/options.py index 1bab0a9..d4b7c1a 100644 --- a/python-spec/src/somacore/options.py +++ b/python-spec/src/somacore/options.py @@ -5,7 +5,7 @@ """ import enum -from typing import Any, Dict, Mapping, Optional, Sequence, TypeVar, Tuple, Union +from typing import Any, Dict, Mapping, Optional, Sequence, Tuple, TypeVar, Union import attrs import numpy as np diff --git a/python-spec/src/somacore/types.py b/python-spec/src/somacore/types.py index 7c152a0..ca8d59f 100644 --- a/python-spec/src/somacore/types.py +++ b/python-spec/src/somacore/types.py @@ -8,7 +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 +57,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