python 3.9 compat

This commit is contained in:
sneakers-the-rat 2024-04-22 20:11:01 -07:00
parent d706d8f1e1
commit 9c306db791
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
3 changed files with 7 additions and 8 deletions

View file

@ -111,7 +111,7 @@ ignore = [
fixable = ["ALL"]
[tool.black]
exclude = ["tests"]
exclude = "tests"
[tool.mypy]
plugins = [

View file

@ -133,7 +133,7 @@ class Interface(ABC, Generic[T]):
"""Input types for all enabled interfaces"""
in_types = []
for iface in cls.interfaces():
if isinstance(iface.input_types, tuple | list):
if isinstance(iface.input_types, Union[tuple, list]):
in_types.extend(iface.input_types)
else:
in_types.append(iface.input_types)

View file

@ -6,13 +6,12 @@ Note that these are types as in python typing types, not classes.
# ruff: noqa: D102
from typing import Any, Protocol, Tuple, runtime_checkable
from typing import Any, Protocol, Tuple, Union, runtime_checkable
import numpy as np
from nptyping import DType
ShapeType = Tuple[int, ...] | Any
DtypeType = np.dtype | str | type | Any | DType
ShapeType = Union[Tuple[int, ...], Any]
DtypeType = Union[str, type, Any, DType]
@runtime_checkable
@ -25,6 +24,6 @@ class NDArrayType(Protocol):
@property
def shape(self) -> ShapeType: ...
def __getitem__(self, key: int | slice) -> "NDArrayType": ...
def __getitem__(self, key: Union[int, slice]) -> "NDArrayType": ...
def __setitem__(self, key: int | slice, value: "NDArrayType"): ...
def __setitem__(self, key: Union[int, slice], value: "NDArrayType"): ...