fix 5.4: return structured types from get_issue/get_pull_request/create_pull_request/update_pull_request
- IssueTools.get_issue now returns IssueModel instead of JSON string - PRTools.get_pull_request now returns PullRequestModel instead of JSON string - PRTools.create_pull_request now returns PullRequestModel instead of JSON string - PRTools.update_pull_request now returns PullRequestModel instead of JSON string - All methods have proper return type hints and raise exceptions on error - Updated tests to verify model objects are returned directly - Marked issue 5.4 as resolved in bad_code.md
This commit is contained in:
@@ -15,12 +15,12 @@ class IssueTools:
|
||||
def __init__(self, client: GiteaClient) -> None:
|
||||
self._client = client
|
||||
|
||||
def get_issue(self, owner: str, repo: str, issue_number: int) -> str:
|
||||
def get_issue(self, owner: str, repo: str, issue_number: int) -> IssueModel:
|
||||
try:
|
||||
issue: IssueModel = self._client.issues.get_issue(owner, repo, issue_number)
|
||||
return issue.model_dump_json(indent=2)
|
||||
return self._client.issues.get_issue(owner, repo, issue_number)
|
||||
except Exception as e:
|
||||
return f"Error getting issue: {str(e)}"
|
||||
logger.error(f"Error getting issue #{issue_number}: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
def close_issue(self, owner: str, repo: str, issue_number: int) -> str:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user