Commit 23cd19fb authored by Jason Fried's avatar Jason Fried Committed by Facebook GitHub Bot
Browse files

typing.NamedTuple.field_types removed in favor of __annotations__

Summary:
typing.NamedTuple was simplified in 3.10
These two fields were the same in 3.8,  so this should be a no-op

#buildmore

Reviewed By: bottler

Differential Revision: D45373526

fbshipit-source-id: 2b26156f5f65b7be335133e9e705730f7254260d
parent 092400f1
......@@ -204,7 +204,7 @@ def _dataclass_list_from_dict_list(dlist, typeannot):
# otherwise, we dispatch by the type of the provided annotation to convert to
if issubclass(cls, tuple) and hasattr(cls, "_fields"): # namedtuple
# For namedtuple, call the function recursively on the lists of corresponding keys
types = cls._field_types.values()
types = cls.__annotations__.values()
dlist_T = zip(*dlist)
res_T = [
_dataclass_list_from_dict_list(key_list, tp)
......@@ -270,7 +270,7 @@ def _dataclass_from_dict(d, typeannot):
cls = get_origin(typeannot) or typeannot
if issubclass(cls, tuple) and hasattr(cls, "_fields"): # namedtuple
types = cls._field_types.values()
types = cls.__annotations__.values()
return cls(*[_dataclass_from_dict(v, tp) for v, tp in zip(d, types)])
elif issubclass(cls, (list, tuple)):
types = get_args(typeannot)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment