File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1- from dataclasses import dataclass , field
1+ from dataclasses import dataclass , field , fields
22from typing import Optional , List , Any , Dict
33from enum import Enum
44import json
@@ -34,7 +34,10 @@ def to_dict(self) -> Dict:
3434 @classmethod
3535 def from_dict (cls , data : Dict ) -> 'BaseModel' :
3636 """Create model from dictionary"""
37- return cls (** data )
37+ # Get only the fields that exist in the dataclass
38+ valid_fields = {f .name for f in fields (cls )}
39+ filtered_data = {k : v for k , v in data .items () if k in valid_fields }
40+ return cls (** filtered_data )
3841
3942 def to_json (self ) -> str :
4043 """Convert model to JSON string"""
@@ -70,6 +73,7 @@ class BaseSecret(BaseModel):
7073 secretComment : str
7174 createdAt : str
7275 updatedAt : str
76+ secretMetadata : Optional [Dict [str , Any ]] = None
7377 secretReminderNote : Optional [str ] = None
7478 secretReminderRepeatDays : Optional [int ] = None
7579 skipMultilineEncoding : Optional [bool ] = False
You can’t perform that action at this time.
0 commit comments