uranusjr commented on a change in pull request #20795:
URL: https://github.com/apache/airflow/pull/20795#discussion_r782015800
##########
File path: airflow/serialization/serialized_objects.py
##########
@@ -975,7 +975,7 @@ def serialize_task_group(cls, task_group: TaskGroup) ->
Optional[Dict[str, Any]]
"children": {
label: (DAT.OP, child.task_id)
if isinstance(child, BaseOperator)
- else (DAT.TASK_GROUP,
SerializedTaskGroup.serialize_task_group(child))
+ else (DAT.TASK_GROUP,
SerializedTaskGroup.serialize_task_group(cast("TaskGroup", child)))
for label, child in task_group.children.items()
},
Review comment:
This feels like a good candidate for poylmorphism. If we have add an
abstract method `serialize_for_task_group` on `DAGNode`, we can do
```python
"children": {
label: child.serialize_for_task_group()
for label, child in task_group.children.items()
}
```
to both avoid the `cast`, and better prevent bugs if we add more `DAGNode`
subclasses in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]