Make `.data.types.Struct.typecast()` work via type lookup from `builtins`
parent
a65910c732
commit
12172cc5cd
|
@ -18,7 +18,8 @@
|
||||||
Built-in (extension) types.
|
Built-in (extension) types.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import sys
|
import builtins
|
||||||
|
# import sys
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
|
||||||
import msgspec
|
import msgspec
|
||||||
|
@ -85,5 +86,11 @@ class Struct(
|
||||||
self,
|
self,
|
||||||
# fields: list[str] | None = None,
|
# fields: list[str] | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
for fname, ftype in self.__annotations__.items():
|
for fname, ftype_str in self.__annotations__.items():
|
||||||
setattr(self, fname, ftype(getattr(self, fname)))
|
ftype = getattr(builtins, ftype_str)
|
||||||
|
attr = getattr(self, fname)
|
||||||
|
setattr(
|
||||||
|
self,
|
||||||
|
fname,
|
||||||
|
ftype(attr),
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue