Ver Fonte

fix: revert converting class to dict using __dict__

trgiangdo há 1 ano atrás
pai
commit
bd45ed17bf
1 ficheiros alterados com 2 adições e 1 exclusões
  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):