o-nikolas commented on code in PR #57563:
URL: https://github.com/apache/airflow/pull/57563#discussion_r2487198639


##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py:
##########
@@ -569,7 +574,7 @@ def try_adopt_task_instances(self, tis: 
Sequence[TaskInstance]) -> Sequence[Task
             tis_to_flush_by_key = {ti.key: ti for ti in tis if 
ti.queued_by_job_id}
             kube_client: client.CoreV1Api = self.kube_client
             for scheduler_job_id in scheduler_job_ids:
-                scheduler_job_id = 
self._make_safe_label_value(str(scheduler_job_id))
+                scheduler_job_id = cast("int", 
self._make_safe_label_value(str(scheduler_job_id)))

Review Comment:
   When I touched this code it was just to reorganize it. It was still doing 
the same logic (with string casting described below).
   
   We want to make a K8s pod label out of the scheduler job id. The job ID is 
an int and the labels are all strings so we cast the job id to a str (that 
existed before this PR) and pass it to the string/label sanitizer. Then the 
result should be a string and we then add the result inside of another string 
with string f-formatting.
   
   The casting and resulting types are all correct, the issue is that the new 
string result is being assigned back to the same variable `scheduler_job_id` 
which is an int type (it's the original carrier of the int job id from the for 
loop). So the result assignment from `self._make_safe_label_value` should be 
assigned to a new variable (maybe `_scheduler_job_id` or 
`scheduler_job_id_safe_label`) and then that used in the string formatting. 
Then MyPy should be happy.



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