1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-09-07 21:58:41 +02:00

Drop unused 'exclude_unset' argument from BaseModel.dict() method

This commit is contained in:
2024-01-04 08:39:06 +01:00
parent 16cdc067a5
commit b8d6c949c9
2 changed files with 11 additions and 9 deletions

View File

@@ -324,16 +324,13 @@ class BaseModel(metaclass=ModelMeta):
self._allow_new_attributes = False
def dict(self, exclude_unset=False):
def dict(self):
result = {}
for name, field in self.__fields__.items():
if field.exclude:
continue
if exclude_unset and field.name not in self._values and field.is_optional:
# include only mandatory fields and optional fields that were set to an actual value
continue
if field.is_model:
result[name] = getattr(self, name).dict(exclude_unset=exclude_unset)
result[name] = getattr(self, name).dict()
else:
result[name] = getattr(self, name)
return result