Ruff
This commit is contained in:
parent
eeac3632b1
commit
77739b0004
|
@ -97,22 +97,23 @@ def create_aider_command(issue: str) -> list[str]:
|
||||||
class GiteaClient:
|
class GiteaClient:
|
||||||
"""
|
"""
|
||||||
Client for interacting with the Gitea API.
|
Client for interacting with the Gitea API.
|
||||||
|
|
||||||
This class provides methods to interact with a Gitea instance's API,
|
This class provides methods to interact with a Gitea instance's API,
|
||||||
including retrieving repository information, creating branches, and fetching issues.
|
including retrieving repository information, creating branches, and fetching issues.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
gitea_url (str): The base URL for the Gitea API endpoints.
|
gitea_url (str): The base URL for the Gitea API endpoints.
|
||||||
session (requests.Session): HTTP session for making API requests.
|
session (requests.Session): HTTP session for making API requests.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, gitea_url: str, token: str) -> None:
|
def __init__(self, gitea_url: str, token: str) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize a new Gitea API client.
|
Initialize a new Gitea API client.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
gitea_url (str): Base URL for the Gitea instance (without '/api/v1').
|
gitea_url (str): Base URL for the Gitea instance (without '/api/v1').
|
||||||
token (str): Authentication token for the Gitea API. If empty, requests will be unauthenticated.
|
token (str): Authentication token for the Gitea API. If empty, requests will be unauthenticated.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
AssertionError: If gitea_url ends with '/api/v1'.
|
AssertionError: If gitea_url ends with '/api/v1'.
|
||||||
"""
|
"""
|
||||||
|
@ -126,15 +127,15 @@ class GiteaClient:
|
||||||
def get_default_branch_sha(self, owner: str, repo: str, branch: str) -> str:
|
def get_default_branch_sha(self, owner: str, repo: str, branch: str) -> str:
|
||||||
"""
|
"""
|
||||||
Retrieve the commit SHA of the specified branch.
|
Retrieve the commit SHA of the specified branch.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
owner (str): Owner of the repository.
|
owner (str): Owner of the repository.
|
||||||
repo (str): Name of the repository.
|
repo (str): Name of the repository.
|
||||||
branch (str): Name of the branch.
|
branch (str): Name of the branch.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: The commit SHA of the specified branch.
|
str: The commit SHA of the specified branch.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
requests.HTTPError: If the API request fails.
|
requests.HTTPError: If the API request fails.
|
||||||
"""
|
"""
|
||||||
|
@ -147,16 +148,16 @@ class GiteaClient:
|
||||||
def create_branch(self, owner: str, repo: str, new_branch: str, sha: str) -> bool:
|
def create_branch(self, owner: str, repo: str, new_branch: str, sha: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Create a new branch from the provided SHA.
|
Create a new branch from the provided SHA.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
owner (str): Owner of the repository.
|
owner (str): Owner of the repository.
|
||||||
repo (str): Name of the repository.
|
repo (str): Name of the repository.
|
||||||
new_branch (str): Name of the new branch to create.
|
new_branch (str): Name of the new branch to create.
|
||||||
sha (str): Commit SHA to use as the starting point for the new branch.
|
sha (str): Commit SHA to use as the starting point for the new branch.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if the branch was created successfully, False if the branch already exists.
|
bool: True if the branch was created successfully, False if the branch already exists.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
requests.HTTPError: If the API request fails for reasons other than branch already existing.
|
requests.HTTPError: If the API request fails for reasons other than branch already existing.
|
||||||
"""
|
"""
|
||||||
|
@ -172,14 +173,14 @@ class GiteaClient:
|
||||||
def get_issues(self, owner: str, repo: str) -> list:
|
def get_issues(self, owner: str, repo: str) -> list:
|
||||||
"""
|
"""
|
||||||
Download issues from the specified repository and filter those with the 'aider' label.
|
Download issues from the specified repository and filter those with the 'aider' label.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
owner (str): Owner of the repository.
|
owner (str): Owner of the repository.
|
||||||
repo (str): Name of the repository.
|
repo (str): Name of the repository.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list: A list of issue dictionaries, filtered to only include issues with the 'aider' label.
|
list: A list of issue dictionaries, filtered to only include issues with the 'aider' label.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
requests.HTTPError: If the API request fails.
|
requests.HTTPError: If the API request fails.
|
||||||
"""
|
"""
|
||||||
|
@ -296,7 +297,11 @@ def solve_issue_in_repository(
|
||||||
run_cmd(['git', 'checkout', '-b', branch_name], tmpdirname)
|
run_cmd(['git', 'checkout', '-b', branch_name], tmpdirname)
|
||||||
|
|
||||||
# Run aider
|
# Run aider
|
||||||
succeeded = run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname, check=False)
|
succeeded = run_cmd(
|
||||||
|
create_aider_command(f'# {issue_title}\n{issue_description}'),
|
||||||
|
tmpdirname,
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
if not succeeded:
|
if not succeeded:
|
||||||
logger.error('Aider invocation failed for issue #%s', issue_number)
|
logger.error('Aider invocation failed for issue #%s', issue_number)
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user