This is an automated email from the ASF dual-hosted git repository.
eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new ff7dcf4e82 replace loop by any when looking for a positive value in
providers (#33984)
ff7dcf4e82 is described below
commit ff7dcf4e829b06d3f8d19b9d14665bac0224b51c
Author: Hussein Awala <[email protected]>
AuthorDate: Fri Sep 1 10:21:33 2023 +0200
replace loop by any when looking for a positive value in providers (#33984)
---
airflow/providers/cncf/kubernetes/operators/pod.py | 6 +-----
airflow/providers/google/cloud/hooks/dataflow.py | 5 +----
2 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/airflow/providers/cncf/kubernetes/operators/pod.py
b/airflow/providers/cncf/kubernetes/operators/pod.py
index 2a02a0bbf6..122315fe40 100644
--- a/airflow/providers/cncf/kubernetes/operators/pod.py
+++ b/airflow/providers/cncf/kubernetes/operators/pod.py
@@ -771,11 +771,7 @@ class KubernetesPodOperator(BaseOperator):
remote_pod = self.pod_manager.read_pod(pod)
- for container in remote_pod.spec.containers:
- if container.name == self.ISTIO_CONTAINER_NAME:
- return True
-
- return False
+ return any(container.name == self.ISTIO_CONTAINER_NAME for container
in remote_pod.spec.containers)
def kill_istio_sidecar(self, pod: V1Pod) -> None:
command = "/bin/sh -c 'curl -fsI -X POST
http://localhost:15020/quitquitquit'"
diff --git a/airflow/providers/google/cloud/hooks/dataflow.py
b/airflow/providers/google/cloud/hooks/dataflow.py
index 3d4f8d75f7..4d155af80e 100644
--- a/airflow/providers/google/cloud/hooks/dataflow.py
+++ b/airflow/providers/google/cloud/hooks/dataflow.py
@@ -226,10 +226,7 @@ class _DataflowJobsController(LoggingMixin):
if not self._jobs:
return False
- for job in self._jobs:
- if job["currentState"] not in DataflowJobStatus.TERMINAL_STATES:
- return True
- return False
+ return any(job["currentState"] not in
DataflowJobStatus.TERMINAL_STATES for job in self._jobs)
def _get_current_jobs(self) -> list[dict]:
"""