uranusjr commented on code in PR #67725:
URL: https://github.com/apache/airflow/pull/67725#discussion_r3478875908


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/partitioned_dag_runs.py:
##########
@@ -463,15 +465,21 @@ def get_pending_partitioned_dag_run(
     total_required = sum(a.required_count for a in assets)
     asset_expression = dag_model.asset_expression if dag_model is not None 
else None
 
-    return PartitionedDagRunDetailResponse(
-        id=partitioned_dag_run.id,
-        dag_id=dag_id,
-        partition_key=partition_key,
-        created_at=partitioned_dag_run.created_at.isoformat() if 
partitioned_dag_run.created_at else None,
-        updated_at=partitioned_dag_run.updated_at.isoformat() if 
partitioned_dag_run.updated_at else None,
-        created_dag_run_id=partitioned_dag_run.created_dag_run_id,
-        assets=assets,
-        total_required=total_required,
-        total_received=total_received,
-        asset_expression=asset_expression,
+    return PartitionedDagRunDetailResponse.model_validate(
+        {
+            "id": partitioned_dag_run.id,
+            "dag_id": dag_id,
+            "partition_key": partition_key,
+            "created_at": partitioned_dag_run.created_at.isoformat()
+            if partitioned_dag_run.created_at
+            else None,
+            "updated_at": partitioned_dag_run.updated_at.isoformat()
+            if partitioned_dag_run.updated_at
+            else None,
+            "created_dag_run_id": partitioned_dag_run.created_dag_run_id,
+            "assets": assets,
+            "total_required": total_required,
+            "total_received": total_received,
+            "asset_expression": asset_expression,
+        }
     )

Review Comment:
   Let’s split this to two statements
   
   ```python
   model_data = {...}
   return Model.model_validate(model_data)
   ```
   
   Using just one statement is fine when the dict is small, but readability 
suffers with larger dict and complex logic inside.



-- 
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]

Reply via email to