Skip to content

Commit cadedda

Browse files
committed
[BugFix] Fix typing.NotRequired reference for Python 3.10
Use the imported NotRequired instead of typing.NotRequired in _is_not_required(), since typing.NotRequired only exists in 3.11+. Made-with: Cursor
1 parent dda393d commit cadedda

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

tensordict/typedtensordict.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from __future__ import annotations
77

8-
import typing
98
from collections.abc import Sequence
109
from typing import Any, ClassVar
1110

@@ -61,7 +60,7 @@ def _get_td_dir() -> frozenset[str]:
6160
def _is_not_required(tp: Any) -> bool:
6261
"""Check whether a type annotation is NotRequired[T]."""
6362
origin = getattr(tp, "__origin__", None)
64-
if origin is typing.NotRequired:
63+
if origin is NotRequired:
6564
return True
6665
origin = getattr(tp, "__class__", None)
6766
if origin is not None and getattr(origin, "__name__", None) == "_SpecialForm":

0 commit comments

Comments
 (0)