Skip to content

Commit bc0ccf9

Browse files
committed
[BugFix] Fix CI failures for Python 3.10 and lint
- Use try/except for NotRequired import in test_typedtensordict.py (NotRequired moved from typing_extensions to typing in 3.11) - Add noqa: D103 to dataclass_transform fallback (pydocstyle) - Remove unused optional_keys variable in _make_init (flake8 F841) Made-with: Cursor
1 parent 6df5b45 commit bc0ccf9

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

tensordict/typedtensordict.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from typing import dataclass_transform
1919
except ImportError:
2020

21-
def dataclass_transform(*args, **kwargs):
21+
def dataclass_transform(*args, **kwargs): # noqa: D103
2222
def _identity(cls):
2323
return cls
2424

@@ -153,7 +153,6 @@ def _make_init(cls: type) -> callable:
153153
non_blocking, lock).
154154
"""
155155
required_keys = cls.__required_keys__
156-
optional_keys = cls.__optional_keys__
157156
expected_keys = cls.__expected_keys__
158157

159158
def __init__(

test/test_typedtensordict.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
from __future__ import annotations
77

8-
from typing import NotRequired
8+
try:
9+
from typing import NotRequired
10+
except ImportError:
11+
from typing_extensions import NotRequired
912

1013
import pytest
1114
import torch

0 commit comments

Comments
 (0)