[Python] fix object arrays giving mypy error "Incompatible types in assignment" in to_dict() (#19223)

* [python] mypy fix for multiple arrays of objects

* [python] mypy test for multiple arrays of objects
This commit is contained in:
VelorumS
2024-07-29 10:34:27 +02:00
committed by GitHub
parent 755b2efee4
commit f082a35d2e
58 changed files with 902 additions and 101 deletions

View File

@@ -92,9 +92,9 @@ class Pet(BaseModel):
# override the default output from pydantic by calling `to_dict()` of each item in tags (list)
_items = []
if self.tags:
for _item in self.tags:
if _item:
_items.append(_item.to_dict())
for _item_tags in self.tags:
if _item_tags:
_items.append(_item_tags.to_dict())
_dict['tags'] = _items
return _dict