Skip to content

Commit c7227f8

Browse files
authored
Add Nested generic type for type hints. (#81)
1 parent 8692270 commit c7227f8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

keras_rs/src/types.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Type definitions."""
22

3-
from typing import Any, Optional, Sequence
3+
from typing import Any, Mapping, Optional, Sequence, TypeVar, Union
44

55
"""
66
A tensor in any of the backends.
@@ -24,3 +24,10 @@
2424
Tensor = Any
2525

2626
TensorShape = Sequence[Optional[int]]
27+
28+
T = TypeVar("T")
29+
Nested = Union[
30+
T,
31+
Sequence[Union[T, "Nested[T]"]],
32+
Mapping[str, Union[T, "Nested[T]"]],
33+
]

0 commit comments

Comments
 (0)