diff --git a/utils/autolabel_issue.py b/utils/autolabel_issue.py index bfaacab7..25485c01 100644 --- a/utils/autolabel_issue.py +++ b/utils/autolabel_issue.py @@ -56,7 +56,7 @@ def get_github_data(endpoint: str) -> dict: def get_event_content() -> Tuple[int, str, str, str]: """Extracts the number, title, body, and username from the issue or pull request.""" - with open(GITHUB_EVENT_PATH, "r") as f: + with open(GITHUB_EVENT_PATH) as f: event_data = json.load(f) if GITHUB_EVENT_NAME == "issues": diff --git a/utils/summarize_release.py b/utils/summarize_release.py index bfefdd54..27499d56 100644 --- a/utils/summarize_release.py +++ b/utils/summarize_release.py @@ -3,6 +3,7 @@ import os import re import subprocess +from datetime import datetime import requests @@ -78,9 +79,13 @@ def get_prs_between_tags(repo_name: str, previous_tag: str, latest_tag: str) -> "body": remove_html_comments(pr_data["body"]), "author": pr_data["user"]["login"], "html_url": pr_data["html_url"], + "merged_at": pr_data["merged_at"], } ) + # Sort PRs by merge date + prs.sort(key=lambda x: datetime.strptime(x["merged_at"], "%Y-%m-%dT%H:%M:%SZ")) + return prs @@ -90,7 +95,7 @@ def generate_release_summary(diff: str, prs: list, latest_tag: str, previous_tag [f"PR #{pr['number']}: {pr['title']} by @{pr['author']}\n{pr['body'][:1000]}..." for pr in prs] ) - current_pr = prs[0] if prs else None + current_pr = prs[-1] if prs else None current_pr_summary = ( f"Current PR #{current_pr['number']}: {current_pr['title']} by @{current_pr['author']}\n{current_pr['body'][:1000]}..." if current_pr diff --git a/utils/update_markdown_code_blocks.py b/utils/update_markdown_code_blocks.py index 54d07fc5..1196a192 100644 --- a/utils/update_markdown_code_blocks.py +++ b/utils/update_markdown_code_blocks.py @@ -96,7 +96,7 @@ def generate_temp_filename(file_path, index): def process_markdown_file(file_path, temp_dir, verbose=False): """Reads a markdown file, extracts Python code blocks, saves them to temp files, and updates the file.""" try: - with open(file_path, "r") as file: + with open(file_path) as file: markdown_content = file.read() code_blocks = extract_code_blocks(markdown_content) @@ -125,7 +125,7 @@ def update_markdown_file(file_path, markdown_content, temp_files): """Updates the markdown file with formatted code blocks.""" for num_spaces, original_code_block, temp_file_path in temp_files: try: - with open(temp_file_path, "r") as temp_file: + with open(temp_file_path) as temp_file: formatted_code = temp_file.read().rstrip("\n") # Strip trailing newlines formatted_code_with_indentation = add_indentation(formatted_code, num_spaces)