Fixing types

This commit is contained in:
Jon Michael Aanes 2025-04-23 22:24:41 +02:00
parent 6db1cccaf8
commit b9013b7b2a
2 changed files with 9 additions and 4 deletions

View File

@ -103,7 +103,11 @@ class RepositoryConfig:
class IssueResolution: class IssueResolution:
success: bool success: bool
pull_request_url: str | None = None pull_request_url: str | None = None
pull_request_id: str | None = None pull_request_id: int | None = None
def __post_init__(self):
assert self.pull_request_id is None or isinstance(self.pull_request_id, int)
assert self.pull_request_url is None or isinstance(self.pull_request_url, str)
def generate_branch_name(issue_number: str, issue_title: str) -> str: def generate_branch_name(issue_number: str, issue_title: str) -> str:
@ -283,8 +287,8 @@ def push_changes(
# Extract PR number and URL if available # Extract PR number and URL if available
return IssueResolution( return IssueResolution(
True, True,
str(pr_response.get('number')),
pr_response.get('html_url'), pr_response.get('html_url'),
int(pr_response.get('number')),
) )
@ -542,7 +546,7 @@ def solve_issues_in_repository(
def handle_pr_comments( def handle_pr_comments(
repository_config, repository_config,
pr_number, pr_number: int,
branch_name, branch_name,
repository_path, repository_path,
client, client,

View File

@ -187,11 +187,12 @@ class GiteaClient:
self, self,
owner: str, owner: str,
repo: str, repo: str,
pr_number: str, pr_number: int,
) -> list[dict]: ) -> list[dict]:
""" """
Fetch comments for a pull request. Fetch comments for a pull request.
""" """
assert isinstance(pr_number, int)
url = f'{self.gitea_url}/repos/{owner}/{repo}/pulls/{pr_number}/comments' url = f'{self.gitea_url}/repos/{owner}/{repo}/pulls/{pr_number}/comments'
response = self.session.get(url) response = self.session.get(url)
response.raise_for_status() response.raise_for_status()