From 7f73434d804a88945df339979e3493ac35fe0113 Mon Sep 17 00:00:00 2001 From: Rob Ambalu Date: Thu, 13 Feb 2025 15:10:02 -0500 Subject: [PATCH] Retire python 3.8 Signed-off-by: Rob Ambalu --- .github/actions/setup-python/action.yml | 1 - .github/workflows/build.yml | 30 ------------------------- csp/impl/types/pydantic_types.py | 23 ------------------- csp/impl/types/typing_utils.py | 29 ++++++------------------ csp/impl/wiring/ast_utils.py | 15 +------------ 5 files changed, 8 insertions(+), 90 deletions(-) diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml index 76bc9e33b..f2e525c3a 100644 --- a/.github/actions/setup-python/action.yml +++ b/.github/actions/setup-python/action.yml @@ -6,7 +6,6 @@ inputs: type: choice description: "Version to install" options: - - '3.8' - '3.9' - '3.10' - '3.11' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7de250edd..e37c137e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -198,7 +198,6 @@ jobs: - macos-14 # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md - windows-2019 # https://github.com/actions/runner-images/blob/main/images/windows/Windows2019-Readme.md python-version: - - "3.8" - "3.9" - "3.10" - "3.11" @@ -217,14 +216,6 @@ jobs: ############################ # Skip when cibuildwheel != python version # to avoid duplication - - python-version: "3.8" - cibuildwheel: "cp39" - - python-version: "3.8" - cibuildwheel: "cp310" - - python-version: "3.8" - cibuildwheel: "cp311" - - python-version: "3.8" - cibuildwheel: "cp312" - python-version: "3.9" cibuildwheel: "cp38" - python-version: "3.9" @@ -263,16 +254,10 @@ jobs: # Things to exclude if not a full matrix run # ############################################## # mac arm builds support py3.10+ - - os: macos-14 - python-version: "3.8" - os: macos-14 python-version: "3.9" # Avoid extra resources for windows build - - is-full-run: false - os: windows-2019 - python-version: "3.8" - - is-full-run: false os: windows-2019 python-version: "3.9" @@ -289,10 +274,6 @@ jobs: - is-full-run: false os: macos-13 - - is-full-run: false - os: macos-14 - python-version: "3.8" - - is-full-run: false os: macos-14 python-version: "3.9" @@ -463,7 +444,6 @@ jobs: - macos-14 - windows-2019 python-version: - - 3.8 - 3.9 - "3.10" - 3.11 @@ -475,16 +455,10 @@ jobs: # Things to exclude if not a full matrix run # ############################################## # mac arm builds support py3.10+ - - os: macos-14 - python-version: "3.8" - os: macos-14 python-version: "3.9" # Avoid extra resources for windows build - - is-full-run: false - os: windows-2019 - python-version: "3.8" - - is-full-run: false os: windows-2019 python-version: "3.9" @@ -501,10 +475,6 @@ jobs: - is-full-run: false os: macos-13 - - is-full-run: false - os: macos-14 - python-version: "3.8" - - is-full-run: false os: macos-14 python-version: "3.9" diff --git a/csp/impl/types/pydantic_types.py b/csp/impl/types/pydantic_types.py index b821934c3..a55277893 100644 --- a/csp/impl/types/pydantic_types.py +++ b/csp/impl/types/pydantic_types.py @@ -11,24 +11,6 @@ from csp.impl.types.tstype import SnapKeyType, SnapType, isTsDynamicBasket from csp.impl.types.typing_utils import TsTypeValidator -# Required for py38 compatibility -# In python 3.8, get_origin(List[float]) returns list, but you can't call list[float] to retrieve the annotation -# Furthermore, Annotated is part of typing_Extensions and get_origin(Annotated[str, ...]) returns str rather than Annotated -_IS_PY38 = sys.version_info < (3, 9) -# For a more complete list, see https://github.com/alexmojaki/eval_type_backport/blob/main/eval_type_backport/eval_type_backport.py -_PY38_ORIGIN_MAP = { - tuple: typing.Tuple, - list: typing.List, - dict: typing.Dict, - set: typing.Set, - frozenset: typing.FrozenSet, - collections.abc.Callable: typing.Callable, - collections.abc.Iterable: typing.Iterable, - collections.abc.Mapping: typing.Mapping, - collections.abc.MutableMapping: typing.MutableMapping, - collections.abc.Sequence: typing.Sequence, -} - _K = TypeVar("T", covariant=True) _T = TypeVar("T", covariant=True) @@ -140,11 +122,6 @@ def adjust_annotations( forced_tvars = forced_tvars or {} origin = get_origin(annotation) - if _IS_PY38: - if isinstance(annotation, typing_extensions._AnnotatedAlias): - return annotation - else: - origin = _PY38_ORIGIN_MAP.get(origin, origin) args = get_args(annotation) if isinstance(annotation, str): annotation = TypeVar(annotation) diff --git a/csp/impl/types/typing_utils.py b/csp/impl/types/typing_utils.py index e0ca15e03..98d75db07 100644 --- a/csp/impl/types/typing_utils.py +++ b/csp/impl/types/typing_utils.py @@ -15,10 +15,14 @@ def __init__(self): raise NotImplementedError("Can not init FastList class") -class CspTypingUtils37: +class CspTypingUtils39: _ORIGIN_COMPAT_MAP = {list: typing.List, set: typing.Set, dict: typing.Dict, tuple: typing.Tuple} _ARRAY_ORIGINS = (csp.typing.Numpy1DArray, csp.typing.NumpyNDArray) - _GENERIC_ALIASES = (typing._GenericAlias,) + _GENERIC_ALIASES = (typing._GenericAlias, typing.GenericAlias) + + @classmethod + def is_generic_container(cls, typ): + return isinstance(typ, cls._GENERIC_ALIASES) and typ.__origin__ is not typing.Union @classmethod def is_type_spec(cls, val): @@ -47,14 +51,6 @@ def is_numpy_array_type(cls, typ): def is_numpy_nd_array_type(cls, typ): return cls.is_numpy_array_type(typ) and cls.get_origin(typ) is csp.typing.NumpyNDArray - # is typ a standard generic container - @classmethod - def is_generic_container(cls, typ): - # isinstance(typing.Callable, typing._GenericAlias) passses in python 3.8, we don't want that - return ( - isinstance(typ, cls._GENERIC_ALIASES) and typ.__origin__ is not typing.Union and typ is not typing.Callable - ) - @classmethod def is_union_type(cls, typ): return isinstance(typ, typing._GenericAlias) and typ.__origin__ is typing.Union @@ -82,19 +78,8 @@ def pretty_typename(cls, typ): return str(typ) -CspTypingUtils = CspTypingUtils37 - -if sys.version_info >= (3, 9): - - class CspTypingUtils39(CspTypingUtils37): - # To support PEP 585 - _GENERIC_ALIASES = (typing._GenericAlias, typing.GenericAlias) - - @classmethod - def is_generic_container(cls, typ): - return isinstance(typ, cls._GENERIC_ALIASES) and typ.__origin__ is not typing.Union +CspTypingUtils = CspTypingUtils39 - CspTypingUtils = CspTypingUtils39 if sys.version_info >= (3, 10): diff --git a/csp/impl/wiring/ast_utils.py b/csp/impl/wiring/ast_utils.py index c6a283f5d..5316750cd 100644 --- a/csp/impl/wiring/ast_utils.py +++ b/csp/impl/wiring/ast_utils.py @@ -3,16 +3,6 @@ import sys -class ASTUtils38: - @staticmethod - def get_subscript_index(subscript: ast.Subscript): - return subscript.slice.value - - @staticmethod - def create_subscript_index(value): - return ast.Index(value=value) - - class ASTUtils39: @staticmethod def get_subscript_index(subscript: ast.Subscript): @@ -23,7 +13,4 @@ def create_subscript_index(value): return value -if sys.version_info.major > 3 or sys.version_info.minor >= 9: - ASTUtils = ASTUtils39 -else: - ASTUtils = ASTUtils38 +ASTUtils = ASTUtils39