Skip to content

Commit

Permalink
replace loop by any when looking for a positive value in providers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-awala authored Sep 1, 2023
1 parent 1b122c1 commit ff7dcf4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
6 changes: 1 addition & 5 deletions airflow/providers/cncf/kubernetes/operators/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,11 +771,7 @@ def is_istio_enabled(self, pod: V1Pod) -> bool:

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'"
Expand Down
5 changes: 1 addition & 4 deletions airflow/providers/google/cloud/hooks/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,7 @@ def is_job_running(self) -> bool:
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]:
"""
Expand Down

0 comments on commit ff7dcf4

Please sign in to comment.