From 7769c2dc5585be13ffd95a0aafddeff96d8d256e Mon Sep 17 00:00:00 2001 From: Rooam Lee Date: Fri, 11 Jul 2025 15:17:52 +0900 Subject: [PATCH 1/3] sample:: test sample code --- sample/calculator.py | 2 +- sample/file_utils.py | 23 ++++++++++++++++------- sample/user.py | 15 +++++++-------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sample/calculator.py b/sample/calculator.py index 4da3c60..a82b26d 100644 --- a/sample/calculator.py +++ b/sample/calculator.py @@ -9,7 +9,7 @@ def multiply(a, b): def divide(a, b): if b == 0: - return "Cannot divide by zero!" + raise ValueError("Cannot divide by zero!") return a / b diff --git a/sample/file_utils.py b/sample/file_utils.py index 0a17c47..219dd7e 100644 --- a/sample/file_utils.py +++ b/sample/file_utils.py @@ -1,11 +1,20 @@ -def read_file(filepath): - with open(filepath, "r") as f: - data = f.read() - return data +def read_file(filepath: str) -> str: + try: + with open(filepath, "r") as f: + return f.read() + except FileNotFoundError: + print(f"File not found: {filepath}") + return "" + except IOError as e: + print(f"Error reading file {filepath}: {e}") + return "" -def write_file(filepath, content): - with open(filepath, "w") as f: - f.write(content) +def write_file(filepath: str, content: str) -> None: + try: + with open(filepath, "w") as f: + f.write(content) + except IOError as e: + print(f"Error writing to file {filepath}: {e}") # def read_file(filepath: str) -> str: diff --git a/sample/user.py b/sample/user.py index b8f101f..5f4bd84 100644 --- a/sample/user.py +++ b/sample/user.py @@ -1,23 +1,22 @@ class User: - def __init__(self, username, email): + def __init__(self, username: str, email: str): self.username = username self.email = email self.logged_in = False - def login(self): + def login(self) -> None: self.logged_in = True - def logout(self): + def logout(self) -> None: self.logged_in = False - def is_logged_in(self): + def is_logged_in(self) -> bool: return self.logged_in - def update_email(self, new_email): + def update_email(self, new_email: str) -> None: if "@" not in new_email: - print("Invalid email address!") - else: - self.email = new_email + raise ValueError("Invalid email address") + self.email = new_email # class User: From c9043fa8dc23489dddbf7afab952dafb54364985 Mon Sep 17 00:00:00 2001 From: Rooam Lee Date: Fri, 11 Jul 2025 15:31:42 +0900 Subject: [PATCH 2/3] Update prmate-review.yml --- .github/workflows/prmate-review.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prmate-review.yml b/.github/workflows/prmate-review.yml index 1654002..e0f4c6c 100644 --- a/.github/workflows/prmate-review.yml +++ b/.github/workflows/prmate-review.yml @@ -18,7 +18,7 @@ env: jobs: job-with-openai: - if: env.OPEN_API_KEY != '' + if: ${{ secrets.OPEN_API_KEY != '' }} runs-on: ubuntu-latest steps: @@ -50,7 +50,7 @@ jobs: job-with-ollama: - if: env.OPEN_API_KEY == '' + if: ${{ secrets.OPEN_API_KEY == '' }} runs-on: self-hosted steps: From a8df3b152d6579c23a74b4afba973bf66e812cac Mon Sep 17 00:00:00 2001 From: Rooam Lee Date: Fri, 11 Jul 2025 15:34:06 +0900 Subject: [PATCH 3/3] Update prmate-review.yml --- .github/workflows/prmate-review.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prmate-review.yml b/.github/workflows/prmate-review.yml index e0f4c6c..829a11c 100644 --- a/.github/workflows/prmate-review.yml +++ b/.github/workflows/prmate-review.yml @@ -16,9 +16,22 @@ env: REVIEW_STRICT: False # Whether to use strict review formatting ("True" to enable strict mode) jobs: + decide-runner: + runs-on: ubuntu-latest + outputs: + use_openai: ${{ steps.set.outputs.use_openai }} + steps: + - id: set + run: | + if [ -z "${{ secrets.OPEN_API_KEY }}" ]; then + echo "use_openai=false" >> "$GITHUB_OUTPUT" + else + echo "use_openai=true" >> "$GITHUB_OUTPUT" + fi job-with-openai: - if: ${{ secrets.OPEN_API_KEY != '' }} + needs: decide-runner + if: ${{ needs.decide-runner.outputs.use_openai == 'true' }} runs-on: ubuntu-latest steps: @@ -50,7 +63,8 @@ jobs: job-with-ollama: - if: ${{ secrets.OPEN_API_KEY == '' }} + needs: decide-runner + if: ${{ needs.decide-runner.outputs.use_openai == 'false' }} runs-on: self-hosted steps: