Skip to content

Commit 9e2a72e

Browse files
committed
(feat) adding support for defining generic symbols (e.g. Symbol[str])
1 parent 0ddea3d commit 9e2a72e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

symai/symbol.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55

66
from box import Box
77
from json import JSONEncoder
8-
from typing import Any, Dict, Iterator, List, Optional, Type, Callable, Tuple
8+
from typing import Any, Dict, Iterator, List, Optional, Type, Callable, Tuple, Generic, TypeVar
99

1010
from . import core
1111
from .ops import SYMBOL_PRIMITIVES
1212

1313

14+
T = TypeVar('T')
15+
16+
1417
class SymbolEncoder(JSONEncoder):
1518
def default(self, o):
1619
'''
@@ -204,7 +207,7 @@ def __new__(mcls, name, bases, attrs):
204207
return cls
205208

206209

207-
class Symbol(metaclass=SymbolMeta):
210+
class Symbol(Generic[T], metaclass=SymbolMeta):
208211
_mixin = True
209212
_primitives = SYMBOL_PRIMITIVES
210213
_metadata = Metadata()

0 commit comments

Comments
 (0)