python 3.9 compat

This commit is contained in:
sneakers-the-rat 2024-09-21 21:30:05 -07:00
parent 74f03b10bf
commit 705de53838
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
2 changed files with 5 additions and 5 deletions

View file

@ -2,7 +2,7 @@
Interface for Dask arrays Interface for Dask arrays
""" """
from typing import Any, Iterable, Literal, Optional from typing import Any, Iterable, List, Literal, Optional, Union
import numpy as np import numpy as np
from pydantic import SerializationInfo from pydantic import SerializationInfo
@ -17,7 +17,7 @@ except ImportError: # pragma: no cover
DaskArray = None DaskArray = None
def _as_tuple(a_list: list | Any) -> tuple: def _as_tuple(a_list: Any) -> tuple:
"""Make a list of list into a tuple of tuples""" """Make a list of list into a tuple of tuples"""
return tuple( return tuple(
[_as_tuple(item) if isinstance(item, list) else item for item in a_list] [_as_tuple(item) if isinstance(item, list) else item for item in a_list]
@ -93,7 +93,7 @@ class DaskInterface(Interface):
@classmethod @classmethod
def to_json( def to_json(
cls, array: DaskArray, info: Optional[SerializationInfo] = None cls, array: DaskArray, info: Optional[SerializationInfo] = None
) -> list | DaskJsonDict: ) -> Union[List, DaskJsonDict]:
""" """
Convert an array to a JSON serializable array by first converting to a numpy Convert an array to a JSON serializable array by first converting to a numpy
array and then to a list. array and then to a list.

View file

@ -65,7 +65,7 @@ class ZarrJsonDict(JsonDict):
path: Optional[str] = None path: Optional[str] = None
array: Optional[list] = None array: Optional[list] = None
def to_array_input(self) -> ZarrArray | ZarrArrayPath: def to_array_input(self) -> Union[ZarrArray, ZarrArrayPath]:
""" """
Construct a ZarrArrayPath if file and path are present, Construct a ZarrArrayPath if file and path are present,
otherwise a ZarrArray otherwise a ZarrArray
@ -168,7 +168,7 @@ class ZarrInterface(Interface):
cls, cls,
array: Union[ZarrArray, str, Path, ZarrArrayPath, Sequence], array: Union[ZarrArray, str, Path, ZarrArrayPath, Sequence],
info: Optional[SerializationInfo] = None, info: Optional[SerializationInfo] = None,
) -> list | ZarrJsonDict: ) -> Union[list, ZarrJsonDict]:
""" """
Dump a Zarr Array to JSON Dump a Zarr Array to JSON