Skip to content

Commit d36eec1

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Better tuple handling
Summary: We can't auto-slotify tuples and `_pytree` includes a direct subclass of `tuple`. We apply the same handling to tuples that we currently apply to named tuples. Reviewed By: martindemello Differential Revision: D96958742 fbshipit-source-id: 2b73528ab35cd7df5c1e174b20184726e8cfd526
1 parent 4f9acc0 commit d36eec1

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

cinderx/PythonLib/cinderx/compiler/static/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ def __init__(
315315
}
316316
typing_extensions_children: dict[str, Value] = {
317317
"Annotated": self.type_env.annotated,
318+
"NamedTuple": self.type_env.named_tuple,
318319
"Protocol": self.type_env.protocol,
319320
"TypedDict": self.type_env.typed_dict,
320321
}

cinderx/PythonLib/cinderx/compiler/static/declaration_visitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def visitClassDef(self, node: ClassDef) -> None:
139139
klass = klasses[0]
140140

141141
for base in bases:
142-
if base is self.type_env.named_tuple:
142+
if base is self.type_env.named_tuple or base is self.type_env.tuple:
143143
# In named tuples, the fields are actually elements
144144
# of the tuple, so we can't do any advanced binding against it.
145145
klass = self.type_env.dynamic

0 commit comments

Comments
 (0)