mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2024-11-10 00:34:29 +00:00
python 3.9 compat
This commit is contained in:
parent
d706d8f1e1
commit
9c306db791
3 changed files with 7 additions and 8 deletions
|
@ -111,7 +111,7 @@ ignore = [
|
||||||
fixable = ["ALL"]
|
fixable = ["ALL"]
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
exclude = ["tests"]
|
exclude = "tests"
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
plugins = [
|
plugins = [
|
||||||
|
|
|
@ -133,7 +133,7 @@ class Interface(ABC, Generic[T]):
|
||||||
"""Input types for all enabled interfaces"""
|
"""Input types for all enabled interfaces"""
|
||||||
in_types = []
|
in_types = []
|
||||||
for iface in cls.interfaces():
|
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)
|
in_types.extend(iface.input_types)
|
||||||
else:
|
else:
|
||||||
in_types.append(iface.input_types)
|
in_types.append(iface.input_types)
|
||||||
|
|
|
@ -6,13 +6,12 @@ Note that these are types as in python typing types, not classes.
|
||||||
|
|
||||||
# ruff: noqa: D102
|
# 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
|
from nptyping import DType
|
||||||
|
|
||||||
ShapeType = Tuple[int, ...] | Any
|
ShapeType = Union[Tuple[int, ...], Any]
|
||||||
DtypeType = np.dtype | str | type | Any | DType
|
DtypeType = Union[str, type, Any, DType]
|
||||||
|
|
||||||
|
|
||||||
@runtime_checkable
|
@runtime_checkable
|
||||||
|
@ -25,6 +24,6 @@ class NDArrayType(Protocol):
|
||||||
@property
|
@property
|
||||||
def shape(self) -> ShapeType: ...
|
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"): ...
|
||||||
|
|
Loading…
Reference in a new issue