浏览代码

fix: revert converting class to dict using __dict__

trgiangdo 1 年之前
父节点
当前提交
bd45ed17bf
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      taipy/core/_repository/_base_taipy_model.py

+ 2 - 1
taipy/core/_repository/_base_taipy_model.py

@@ -9,6 +9,7 @@
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations under the License.
 
+import dataclasses
 import enum
 import json
 from typing import Any, Dict
@@ -27,7 +28,7 @@ class _BaseModel:
             yield attr, value
 
     def to_dict(self) -> Dict[str, Any]:
-        model_dict = {**self.__dict__}
+        model_dict = {**dataclasses.asdict(self)}  # type: ignore[call-overload]
 
         for k, v in model_dict.items():
             if isinstance(v, enum.Enum):