Skip to content

Commit d73fc9a

Browse files
ConchylicultorThe dataclass_array Authors
authored andcommitted
Fix next release pytype errors
PiperOrigin-RevId: 544331428
1 parent 2c93efa commit d73fc9a

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

dataclass_array/array_dataclass.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from dataclass_array import shape_parsing
2626
from dataclass_array import type_parsing
2727
from dataclass_array.typing import Array
28-
from dataclass_array.typing import Axes, DcOrArray, DcOrArrayT, DTypeArg, DynamicShape, Shape # pylint: disable=g-multiple-import
28+
from dataclass_array.typing import Axes, DTypeArg, DcOrArray, DcOrArrayT, DynamicShape, Shape # pylint: disable=g-multiple-import,g-importing-member
2929
from dataclass_array.utils import np_utils
3030
from dataclass_array.utils import py_utils
3131
import einops
@@ -37,8 +37,6 @@
3737
import typing_extensions
3838
from typing_extensions import Annotated, Literal, TypeAlias # pylint: disable=g-multiple-import
3939

40-
if typing.TYPE_CHECKING:
41-
import torch # pytype: disable=import-error
4240

4341
lazy = enp.lazy
4442

@@ -152,15 +150,16 @@ def __getitem__(cls, spec):
152150
return Annotated[cls, field_utils.ShapeAnnotation(spec)]
153151

154152

155-
@typing_extensions.dataclass_transform( # pytype: disable=not-supported-yet
156-
kw_only_default=True,
157-
# TODO(b/272524683):Restore field specifier
158-
# field_specifiers=(
159-
# dataclasses.Field,
160-
# dataclasses.field,
161-
# array_field,
162-
# ),
163-
)
153+
# TODO(epot): Restore once pytype support this
154+
# @typing_extensions.dataclass_transform(
155+
# kw_only_default=True,
156+
# # TODO(b/272524683):Restore field specifier
157+
# # field_specifiers=(
158+
# # dataclasses.Field,
159+
# # dataclasses.field,
160+
# # array_field,
161+
# # ),
162+
# )
164163
class DataclassArray(metaclass=MetaDataclassArray):
165164
"""Dataclass which behaves like an array.
166165

dataclass_array/typing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
from typing import Any, Optional, Tuple, Type, TypeVar, Union
2121

2222
from etils import enp
23-
from etils.array_types import FloatArray
2423

2524
if typing.TYPE_CHECKING:
26-
from dataclass_array import array_dataclass
25+
from dataclass_array import array_dataclass # pylint: disable=g-bad-import-order,unused-import
2726

2827
# ======== Array types (alias of `enp.typing`) ========
2928

dataclass_array/utils/tree_utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@
2222
from __future__ import annotations
2323

2424
import collections.abc
25-
from typing import Callable, TypeVar
25+
from typing import Any, Callable, TypeVar
2626

2727
from etils import epy
28-
from etils.etree.typing import Tree
29-
from typing_extensions import Unpack, TypeVarTuple # pytype: disable=not-supported-yet # pylint: disable=g-multiple-import
28+
from etils.etree.typing import Tree # pylint: disable=g-importing-member
29+
from typing_extensions import TypeVarTuple, Unpack # pytype: disable=not-supported-yet # pylint: disable=g-multiple-import
3030

31-
_InsT = TypeVarTuple('_InsT')
32-
_OutT = TypeVar('_OutT')
31+
# TODO(epot): Remove once pytype support `Unpack`
32+
del TypeVar, TypeVarTuple, Unpack
33+
Unpack = Any
34+
TypeVarTuple = Any
35+
36+
_InsT = Any # TypeVarTuple('_InsT')
37+
_OutT = Any # TypeVar('_OutT')
3338

3439

3540
def tree_map( # pylint: disable=redefined-builtin

0 commit comments

Comments
 (0)