Skip to content

Commit

Permalink
Retire python 3.8
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Ambalu <[email protected]>
  • Loading branch information
robambalu committed Feb 13, 2025
1 parent 0a72f34 commit 7f73434
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 90 deletions.
1 change: 0 additions & 1 deletion .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ inputs:
type: choice
description: "Version to install"
options:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -463,7 +444,6 @@ jobs:
- macos-14
- windows-2019
python-version:
- 3.8
- 3.9
- "3.10"
- 3.11
Expand All @@ -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"
Expand All @@ -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"
Expand Down
23 changes: 0 additions & 23 deletions csp/impl/types/pydantic_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
29 changes: 7 additions & 22 deletions csp/impl/types/typing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):

Expand Down
15 changes: 1 addition & 14 deletions csp/impl/wiring/ast_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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

0 comments on commit 7f73434

Please sign in to comment.