Ruff after aider
All checks were successful
Run Python tests (through Pytest) / Test (push) Successful in 25s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 22s

This commit is contained in:
Jon Michael Aanes 2025-04-15 23:35:59 +02:00
parent 6aa2a3fcc4
commit 3fa44e08d8
4 changed files with 42 additions and 40 deletions

View File

@ -254,7 +254,9 @@ def push_changes(
# Store PR information in the database if available # Store PR information in the database if available
if seen_issues_db and issue_text and pr_number and pr_url: if seen_issues_db and issue_text and pr_number and pr_url:
seen_issues_db.update_pr_info(issue_text, pr_number, pr_url) seen_issues_db.update_pr_info(issue_text, pr_number, pr_url)
logger.info('Stored PR #%s information for issue #%s', pr_number, issue_number) logger.info(
'Stored PR #%s information for issue #%s', pr_number, issue_number,
)
return True, pr_number, pr_url return True, pr_number, pr_url

View File

@ -7,7 +7,6 @@ store information about seen issues and their associated pull requests for effic
import sqlite3 import sqlite3
from hashlib import sha256 from hashlib import sha256
from typing import Optional, Tuple
DEFAULT_DB_PATH = 'output/seen_issues.db' DEFAULT_DB_PATH = 'output/seen_issues.db'
@ -49,7 +48,13 @@ class SeenIssuesDB:
) )
""") """)
def mark_as_seen(self, issue_text: str, issue_number: str = None, pr_number: str = None, pr_url: str = None): def mark_as_seen(
self,
issue_text: str,
issue_number: str = None,
pr_number: str = None,
pr_url: str = None,
):
"""Mark an issue as seen in the database. """Mark an issue as seen in the database.
Computes a hash of the issue text and stores it in the database along with pull request information. Computes a hash of the issue text and stores it in the database along with pull request information.
@ -86,7 +91,7 @@ class SeenIssuesDB:
) )
return cursor.fetchone() is not None return cursor.fetchone() is not None
def get_pr_info(self, issue_text: str) -> Optional[Tuple[str, str]]: def get_pr_info(self, issue_text: str) -> tuple[str, str] | None:
"""Get pull request information for an issue. """Get pull request information for an issue.
Args: Args:

View File

@ -1,8 +1,5 @@
import os import os
import tempfile import tempfile
from pathlib import Path
import pytest
from aider_gitea.seen_issues_db import SeenIssuesDB from aider_gitea.seen_issues_db import SeenIssuesDB
@ -14,10 +11,10 @@ class TestSeenIssuesDBPRInfo:
self.db = SeenIssuesDB(self.db_path) self.db = SeenIssuesDB(self.db_path)
# Test data # Test data
self.issue_text = "Test issue title\nTest issue description" self.issue_text = 'Test issue title\nTest issue description'
self.issue_number = "123" self.issue_number = '123'
self.pr_number = "456" self.pr_number = '456'
self.pr_url = "https://gitea.example.com/owner/repo/pulls/456" self.pr_url = 'https://gitea.example.com/owner/repo/pulls/456'
def teardown_method(self): def teardown_method(self):
# Close and remove the temporary database # Close and remove the temporary database
@ -31,7 +28,7 @@ class TestSeenIssuesDBPRInfo:
self.issue_text, self.issue_text,
issue_number=self.issue_number, issue_number=self.issue_number,
pr_number=self.pr_number, pr_number=self.pr_number,
pr_url=self.pr_url pr_url=self.pr_url,
) )
# Verify the issue is marked as seen # Verify the issue is marked as seen
@ -51,11 +48,7 @@ class TestSeenIssuesDBPRInfo:
assert self.db.get_pr_info(self.issue_text) == (None, None) assert self.db.get_pr_info(self.issue_text) == (None, None)
# Update with PR info # Update with PR info
updated = self.db.update_pr_info( updated = self.db.update_pr_info(self.issue_text, self.pr_number, self.pr_url)
self.issue_text,
self.pr_number,
self.pr_url
)
# Verify update was successful # Verify update was successful
assert updated assert updated
@ -68,9 +61,7 @@ class TestSeenIssuesDBPRInfo:
def test_update_nonexistent_issue(self): def test_update_nonexistent_issue(self):
# Try to update PR info for an issue that doesn't exist # Try to update PR info for an issue that doesn't exist
updated = self.db.update_pr_info( updated = self.db.update_pr_info(
"Nonexistent issue", 'Nonexistent issue', self.pr_number, self.pr_url,
self.pr_number,
self.pr_url
) )
# Verify update failed # Verify update failed
@ -78,7 +69,7 @@ class TestSeenIssuesDBPRInfo:
def test_get_pr_info_nonexistent(self): def test_get_pr_info_nonexistent(self):
# Try to get PR info for an issue that doesn't exist # Try to get PR info for an issue that doesn't exist
pr_info = self.db.get_pr_info("Nonexistent issue") pr_info = self.db.get_pr_info('Nonexistent issue')
# Verify no PR info is available # Verify no PR info is available
assert pr_info is None assert pr_info is None

View File

@ -32,7 +32,11 @@ class TestSolveIssueInRepository:
): ):
# Setup mocks # Setup mocks
mock_run_cmd.return_value = True mock_run_cmd.return_value = True
mock_push_changes.return_value = (True, '456', 'https://gitea.example.com/test-owner/test-repo/pulls/456') mock_push_changes.return_value = (
True,
'456',
'https://gitea.example.com/test-owner/test-repo/pulls/456',
)
# Mock subprocess.run to return different commit hashes and file changes # Mock subprocess.run to return different commit hashes and file changes
mock_subprocess_run.side_effect = [ mock_subprocess_run.side_effect = [