Skip to content

Commit 88b5a43

Browse files
author
Tim Joseph
committed
style(utils): update type hints and add future annotations import
Adopt modern Python 3.10+ type hint syntax by using the union operator `|` instead of `Optional[...]`. Also, add `from __future__ import annotations` to enable postponed evaluation of type annotations, improving flexibility and consistency for type checking.
1 parent fea80fb commit 88b5a43

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tensorcontainer/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from abc import ABC, abstractmethod
24
from dataclasses import dataclass
35
from typing import (
@@ -283,7 +285,7 @@ def _get_guidance(self) -> str:
283285
def diagnose_pytree_structure_mismatch(
284286
tree: PyTree,
285287
*rests: tuple[PyTree],
286-
is_leaf: Optional[Callable[[PyTree], bool]] = None,
288+
is_leaf: Callable[[PyTree], bool] | None = None,
287289
) -> StructureMismatch | None:
288290
"""Diagnoses if all PyTrees have identical structure for operations requiring uniformity.
289291

0 commit comments

Comments
 (0)