Fixes: 1) Correct invalid return type in get_children; 2) Update default return value from {} to [];

Extra: 1) Adjust inline comments for better clarity; 2) General cleanup in `simple.py`.
This commit is contained in:
Egor Pavlovich Gorbunov 2025-12-22 13:53:04 +03:00
parent e312cb8a71
commit e9219c8918

View file

@ -52,7 +52,7 @@ class CategorySimpleSerializer(ModelSerializer):
"children",
]
def get_children(self, obj: Category) -> dict[str, Any]:
def get_children(self, obj: Category) -> list[dict[str, Any]]:
request = self.context.get("request")
if request is not None and request.user.has_perm("view_category"):
children = obj.children.all()
@ -63,8 +63,8 @@ class CategorySimpleSerializer(ModelSerializer):
serializer = CategorySimpleSerializer(
children, many=True, context=self.context
)
return dict(serializer.data) # ty: ignore[invalid-return-type]
return {}
return list(serializer.data)
return []
class BrandSimpleSerializer(ModelSerializer):