Skip to content

Commit 114813c

Browse files
RohitRathore1pytorchmergebot
authored andcommitted
Fix mypy errors: PyTreeSpec inheritance (#160652)
Fixes #160650. I added type ignore comment to `LeafSpec` class inheritance in `torch/utils/_cxx_pytree.py` to handle `PyTreeSpec` being marked as final in optree's type stubs. Pull Request resolved: #160652 Approved by: https://github.com/Skylion007
1 parent 11b6ceb commit 114813c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

torch/utils/_cxx_pytree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ def __instancecheck__(self, instance: object) -> bool:
994994
return _is_pytreespec_instance(instance) and instance.is_leaf()
995995

996996

997-
class LeafSpec(TreeSpec, metaclass=LeafSpecMeta):
997+
class LeafSpec(TreeSpec, metaclass=LeafSpecMeta): # type: ignore[misc,final]
998998
def __new__(cls) -> "LeafSpec":
999999
return optree.treespec_leaf(none_is_leaf=True) # type: ignore[return-value]
10001000

0 commit comments

Comments
 (0)