Fix custom elements nested under @property (#3066)

* patch custom elements bug

* Skip `cached_property`

* fomrat

* comment, type hint

---------

Co-authored-by: Brent Yi <yibrenth@gmail.com>
This commit is contained in:
Justin KerrandBrent Yi authored and GitHub committed 2024-04-10 18:59:20 -07:00
1 parent d1fc2ee338
commit c381fc818d
1 file changed
+5 -3
+5 -3
View File
@@ -15,7 +15,8 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, List, Literal, Optional, Tuple, Union
from functools import cached_property
from typing import Any, List, Literal, Optional, Tuple, Type, Union
import numpy as np
import torch
@@ -109,7 +110,7 @@ def update_render_aabb(
def parse_object(
obj: Any,
type_check,
type_check: Type[Any],
tree_stub: str,
) -> List[Tuple[str, Any]]:
"""
@@ -138,7 +139,8 @@ def parse_object(
return []
ret = []
# get a list of the properties of the object, sorted by whether things are instances of type_check
obj_props = [(k, v) for k, v in vars(obj).items()]
# we skip cached properties, which can be expensive to call `getattr()` on!
obj_props = [(k, getattr(obj, k)) for k in dir(obj) if not isinstance(getattr(type(obj), k, None), cached_property)]
for k, v in obj_props:
if k[0] == "_":
continue