Skip to content

Commit fd2f7f0

Browse files
committed
fix(typing): add @runtime_checkable decorator for CustomTreeNode protocal class
1 parent cf37e8c commit fd2f7f0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

optree/typing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
Union,
3939
)
4040
from typing_extensions import OrderedDict # Generic OrderedDict: Python 3.7.2+
41-
from typing_extensions import Protocol # Python 3.8+
4241
from typing_extensions import TypeAlias # Python 3.10+
42+
from typing_extensions import Protocol, runtime_checkable # Python 3.8+
4343

4444
from optree import _C
4545

@@ -99,6 +99,7 @@
9999
MetaData = Optional[_MetaData]
100100

101101

102+
@runtime_checkable
102103
class CustomTreeNode(Protocol[T]):
103104
"""The abstract base class for custom pytree nodes."""
104105

0 commit comments

Comments
 (0)