diff --git a/dev/check_files.py b/dev/check_files.py index c8085c806670..52260c1da293 100644 --- a/dev/check_files.py +++ b/dev/check_files.py @@ -141,7 +141,7 @@ def check_release(files: list[str], version: str): def expand_name_variations(files): - return list(sorted(base + suffix for base, suffix in product(files, ["", ".asc", ".sha512"]))) + return sorted(base + suffix for base, suffix in product(files, ["", ".asc", ".sha512"])) def check_upgrade_check(files: list[str], version: str): diff --git a/dev/perf/dags/elastic_dag.py b/dev/perf/dags/elastic_dag.py index c8b4ec1c2905..ce61785643d6 100644 --- a/dev/perf/dags/elastic_dag.py +++ b/dev/perf/dags/elastic_dag.py @@ -106,7 +106,7 @@ def chain_as_grid(*tasks: BashOperator): """ if len(tasks) > 100 * 99 / 2: raise ValueError("Cannot generate grid DAGs with lateral size larger than 100 tasks.") - grid_size = min(n for n in range(100) if n * (n + 1) / 2 >= len(tasks)) + grid_size = next(n for n in range(100) if n * (n + 1) / 2 >= len(tasks)) def index(i, j): """ diff --git a/dev/send_email.py b/dev/send_email.py index 505eb73fca09..575474e2a196 100755 --- a/dev/send_email.py +++ b/dev/send_email.py @@ -304,7 +304,7 @@ def result( @cli.command("announce") @click.option( "--receiver_email", - default=",".join(list(MAILING_LIST.values())), + default=",".join(MAILING_LIST.values()), prompt="The receiver email (To:)", help="Receiver's email address. If more than 1, separate them by comma", ) diff --git a/dev/stats/get_important_pr_candidates.py b/dev/stats/get_important_pr_candidates.py index b54139de0258..3830953c6fb1 100755 --- a/dev/stats/get_important_pr_candidates.py +++ b/dev/stats/get_important_pr_candidates.py @@ -17,6 +17,7 @@ # under the License. from __future__ import annotations +import heapq import logging import math import pickle @@ -346,9 +347,7 @@ def main( if load: console.print("Loading PRs from cache and recalculating scores.") selected_prs = pickle.load(load, encoding="bytes") - issue_num = 0 - for pr in selected_prs: - issue_num += 1 + for issue_num, pr in enumerate(selected_prs, 1): console.print( f"[green]Loading PR: #{pr.pull_request.number} `{pr.pull_request.title}`.[/]" f" Score: {pr.score}." @@ -363,12 +362,10 @@ def main( repo = g.get_repo("apache/airflow") commits = repo.get_commits(since=date_start, until=date_end) pulls: list[PullRequest] = [pull for commit in commits for pull in commit.get_pulls()] - issue_num = 0 scores: dict = {} - for pull in pulls: + for issue_num, pull in enumerate(pulls, 1): p = PrStat(g=g, pull_request=pull) # type: ignore scores.update({pull.number: [p.score, pull.title]}) - issue_num += 1 console.print( f"[green]Selecting PR: #{pull.number} `{pull.title}` as candidate.[/]" f" Score: {scores[pull.number][0]}." @@ -384,7 +381,7 @@ def main( break console.print(f"Top {top_number} out of {issue_num} PRs:") - for pr_scored in sorted(scores.items(), key=lambda s: s[1], reverse=True)[:top_number]: + for pr_scored in heapq.nlargest(top_number, scores.items(), key=lambda s: s[1]): console.print(f"[green] * PR #{pr_scored[0]}: {pr_scored[1][1]}. Score: [magenta]{pr_scored[1][0]}") if save: