From 62d438c71509258f6f15e204356f7cabb097ca96 Mon Sep 17 00:00:00 2001 From: dharsh03rs-cpu Date: Fri, 21 Aug 2026 13:34:31 +0530 Subject: [PATCH 1/6] fix:bucket count type --- sorts/bucket_sort.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sorts/bucket_sort.py b/sorts/bucket_sort.py index 893c7ff3a23a..15bc72b956d4 100644 --- a/sorts/bucket_sort.py +++ b/sorts/bucket_sort.py @@ -71,8 +71,13 @@ def bucket_sort(my_list: list, bucket_count: int = 10) -> list: >>> data = [9, 2, 7, 1, 5] >>> bucket_sort(data) == sorted(data) True + >>> bucket_sort(data, 3.5) + Traceback (most recent call last): + ... + TypeError: bucket_count must be an integer """ - + if type(bucket_count) != int: + raise TypeError("bucket_count must be an integer") if len(my_list) == 0 or bucket_count <= 0: return [] From bc4ce507da2938323dc6bc3bf1baf0fda3413c0b Mon Sep 17 00:00:00 2001 From: dharsh03rs-cpu Date: Fri, 21 Aug 2026 13:57:45 +0530 Subject: [PATCH 2/6] fixed TypeError --- sorts/bucket_sort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorts/bucket_sort.py b/sorts/bucket_sort.py index 15bc72b956d4..482d5b74204d 100644 --- a/sorts/bucket_sort.py +++ b/sorts/bucket_sort.py @@ -76,7 +76,7 @@ def bucket_sort(my_list: list, bucket_count: int = 10) -> list: ... TypeError: bucket_count must be an integer """ - if type(bucket_count) != int: + if type(bucket_count) is not int: raise TypeError("bucket_count must be an integer") if len(my_list) == 0 or bucket_count <= 0: return [] From 11d42c7932e5a8d5676790c7b174ea1fd958c7e0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 13 Sep 2026 09:15:16 +0200 Subject: [PATCH 3/6] Refine docstring and adjust return statement Updated docstring for partition_liked_list method to clarify behavior. Changed return statement from None to None for consistency. --- data_structures/linked_list/partition_linked_list.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data_structures/linked_list/partition_linked_list.py b/data_structures/linked_list/partition_linked_list.py index 6cc9a66793b8..52bc5ed35989 100644 --- a/data_structures/linked_list/partition_linked_list.py +++ b/data_structures/linked_list/partition_linked_list.py @@ -103,9 +103,9 @@ def add(self, item: Any, position: int = 0) -> None: def partition_liked_list(self, value: int) -> None: """ - Partition Linked List based on node elements in-order. - All nodes with elements less than value should occur in the left, - while those greater than to value, in the right. + Partition the linked list based on node elements in order. + All nodes with elements less than value should occur on the left, + while those greater than or equal to value should occur on the right. >>> linked_list = LinkedList() >>> linked_list.add(1) @@ -156,7 +156,7 @@ def partition_liked_list(self, value: int) -> None: 1 """ if self.head is None: - return None + return less_nodes, greater_nodes = Node(0), Node(0) current, current_less, current_greater = self.head, less_nodes, greater_nodes From 32c26773cc4d49426a2a1b40befa0b17f1b02a74 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 13 Sep 2026 09:18:33 +0200 Subject: [PATCH 4/6] Add script to map open PRs to modified files This script lists all open pull requests in the current directory's git repository and maps each file touched by any open PR to its corresponding PR numbers. It outputs the results in GitHub-flavored Markdown format. --- scripts/pr_file_map.py | 113 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 scripts/pr_file_map.py diff --git a/scripts/pr_file_map.py b/scripts/pr_file_map.py new file mode 100644 index 000000000000..ef79b102e4ca --- /dev/null +++ b/scripts/pr_file_map.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python3 +""" +pr_file_map.py + +Lists all open pull requests in the current directory's git repo (via `gh`) +and, for each file touched by any open PR, which PR number(s) touch it. + +Output is GitHub-flavored Markdown: a sorted list of files that currently +exist in the working directory, each with its modifying PR numbers, followed +by a separate section for files referenced by open PRs but that do not exist +in the working directory (e.g. deleted, renamed, or on a branch not checked +out locally). + +Requirements: gh (GitHub CLI), authenticated (`gh auth login`) + +Usage: + ./pr_file_map.py + ./pr_file_map.py > report.md +""" + +import json +import os +import shutil +import subprocess +import sys +from collections import defaultdict + + +def run_gh(args: list[str]) -> str: + try: + result = subprocess.run( + ["gh", *args], + capture_output=True, + text=True, + check=True, + ) + except FileNotFoundError: + sys.exit("Error: 'gh' (GitHub CLI) is not installed or not in PATH.") + except subprocess.CalledProcessError as e: + sys.exit(f"Error running 'gh {' '.join(args)}':\n{e.stderr.strip()}") + return result.stdout + + +def check_gh_auth() -> None: + try: + subprocess.run( + ["gh", "auth", "status"], + capture_output=True, + text=True, + check=True, + ) + except subprocess.CalledProcessError: + sys.exit("Error: gh is not authenticated. Run 'gh auth login' first.") + + +def get_open_prs() -> list[dict]: + raw = run_gh(["pr", "list", "--state", "open", "--limit", "1000", "--json", "number,title"]) + return json.loads(raw) + + +def get_pr_files(pr_number: int) -> list[str]: + raw = run_gh(["pr", "view", str(pr_number), "--json", "files"]) + data = json.loads(raw) + return [f["path"] for f in data.get("files", [])] + + +def main() -> None: + if shutil.which("gh") is None: + sys.exit("Error: 'gh' (GitHub CLI) is not installed or not in PATH.") + + check_gh_auth() + + prs = get_open_prs() + if not prs: + print("No open pull requests found.") + return + + file_to_prs: dict[str, list[int]] = defaultdict(list) + + for pr in prs: + pr_number = pr["number"] + for path in get_pr_files(pr_number): + file_to_prs[path].append(pr_number) + + existing: dict[str, list[int]] = {} + missing: dict[str, list[int]] = {} + + for path, pr_numbers in file_to_prs.items(): + target = existing if os.path.exists(path) else missing + target[path] = sorted(set(pr_numbers)) + + # --- Render GitHub-flavored Markdown --- + print("# Open Pull Request File Map\n") + + print("## Existing files\n") + if existing: + for path in sorted(existing): + pr_list = " ".join(f"#{n}" for n in existing[path]) + print(f"- `{path}`: {pr_list}") + else: + print("_None._") + + print("\n## Files not present in the working directory\n") + if missing: + for path in sorted(missing): + pr_list = " ".join(f"#{n}" for n in missing[path]) + print(f"- `{path}`: {pr_list}") + else: + print("_None._") + + +if __name__ == "__main__": + main() From ca13a25afda14e18c6ff5dc3e509dabdca02ccf8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 13 Sep 2026 07:18:46 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/pr_file_map.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/pr_file_map.py b/scripts/pr_file_map.py index ef79b102e4ca..709341769cbf 100644 --- a/scripts/pr_file_map.py +++ b/scripts/pr_file_map.py @@ -54,7 +54,9 @@ def check_gh_auth() -> None: def get_open_prs() -> list[dict]: - raw = run_gh(["pr", "list", "--state", "open", "--limit", "1000", "--json", "number,title"]) + raw = run_gh( + ["pr", "list", "--state", "open", "--limit", "1000", "--json", "number,title"] + ) return json.loads(raw) From 19a782737b9d45c7e4ca4b79f6577021d92ac7bc Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 13 Sep 2026 09:23:37 +0200 Subject: [PATCH 6/6] Add noqa comments for subprocess calls Add noqa comments to suppress specific linting warnings. --- scripts/pr_file_map.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/pr_file_map.py b/scripts/pr_file_map.py index 709341769cbf..338c7f95d4ac 100644 --- a/scripts/pr_file_map.py +++ b/scripts/pr_file_map.py @@ -28,8 +28,8 @@ def run_gh(args: list[str]) -> str: try: - result = subprocess.run( - ["gh", *args], + result = subprocess.run( # noqa: S603 + ["gh", *args], # noqa: S607 capture_output=True, text=True, check=True, @@ -44,7 +44,7 @@ def run_gh(args: list[str]) -> str: def check_gh_auth() -> None: try: subprocess.run( - ["gh", "auth", "status"], + ["gh", "auth", "status"], # noqa: S607 capture_output=True, text=True, check=True,