This is an automated email from the ASF dual-hosted git repository.
potiuk 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 3b313e218d Refactor: Simplofy code in dev (#33294)
3b313e218d is described below
commit 3b313e218d17ba07757ce08acdceab7620fb4fd6
Author: Miroslav Šedivý <[email protected]>
AuthorDate: Thu Aug 10 23:09:10 2023 +0000
Refactor: Simplofy code in dev (#33294)
---
dev/check_files.py | 2 +-
dev/perf/dags/elastic_dag.py | 2 +-
dev/send_email.py | 2 +-
dev/stats/get_important_pr_candidates.py | 11 ++++-------
4 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/dev/check_files.py b/dev/check_files.py
index c8085c8066..52260c1da2 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 c8b4ec1c29..ce61785643 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 505eb73fca..575474e2a1 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 b54139de02..3830953c6f 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: