Skip to content

Commit

Permalink
Merge lines to improve readability
Browse files Browse the repository at this point in the history
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
  • Loading branch information
2 people authored and potiuk committed Mar 12, 2023
1 parent b275f87 commit 5679b29
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions airflow/providers/amazon/aws/hooks/emr.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ def get_cluster_id_by_name(self, emr_cluster_name: str, cluster_states: list[str
response_iterator = (
self.get_conn().get_paginator("list_clusters").paginate(ClusterStates=cluster_states)
)
matching_clusters = []
for page in response_iterator:
matching_clusters.extend(
list(filter(lambda cluster: cluster["Name"] == emr_cluster_name, page["Clusters"]))
)
matching_clusters = [
cluster
for page in response_iterator
for cluster in page["Clusters"]
if cluster["Name"] == emr_cluster_name
]

if len(matching_clusters) == 1:
cluster_id = matching_clusters[0]["Id"]
Expand Down

0 comments on commit 5679b29

Please sign in to comment.