Skip to content

Commit 711f501

Browse files
author
Josh Bendson
committed
chore: Fix linting and formatting in server tests
- Remove unused imports (F401 errors) - Remove unused variables (F841 errors) - Apply black formatting to server code and tests - Required for server-fast-automation.sh to pass
1 parent 11bbff9 commit 711f501

56 files changed

Lines changed: 1068 additions & 626 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/code_indexer/server/app.py

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,18 +1931,7 @@ def create_app() -> FastAPI:
19311931
Returns:
19321932
Configured FastAPI app
19331933
"""
1934-
global \
1935-
jwt_manager, \
1936-
user_manager, \
1937-
refresh_token_manager, \
1938-
golden_repo_manager, \
1939-
background_job_manager, \
1940-
activated_repo_manager, \
1941-
repository_listing_manager, \
1942-
semantic_query_manager, \
1943-
_server_start_time, \
1944-
_server_hnsw_cache, \
1945-
_server_fts_cache
1934+
global jwt_manager, user_manager, refresh_token_manager, golden_repo_manager, background_job_manager, activated_repo_manager, repository_listing_manager, semantic_query_manager, _server_start_time, _server_hnsw_cache, _server_fts_cache
19461935

19471936
# Story #526: Initialize server-side HNSW cache at bootstrap for 1800x performance
19481937
# Import and initialize global cache instance
@@ -5939,30 +5928,28 @@ async def semantic_query(
59395928
# Execute semantic search for hybrid or degraded mode
59405929
if search_mode_actual in ["semantic", "hybrid"]:
59415930
try:
5942-
semantic_results_raw = (
5943-
semantic_query_manager.query_user_repositories(
5944-
username=current_user.username,
5945-
query_text=request.query_text,
5946-
repository_alias=request.repository_alias,
5947-
limit=request.limit,
5948-
min_score=request.min_score,
5949-
file_extensions=request.file_extensions,
5950-
# Phase 1 parameters (Story #503)
5951-
exclude_language=request.exclude_language,
5952-
exclude_path=request.exclude_path,
5953-
accuracy=request.accuracy,
5954-
# Temporal parameters (Story #446)
5955-
time_range=request.time_range,
5956-
time_range_all=request.time_range_all,
5957-
at_commit=request.at_commit,
5958-
include_removed=request.include_removed,
5959-
show_evolution=request.show_evolution,
5960-
evolution_limit=request.evolution_limit,
5961-
# Phase 3 temporal filtering parameters (Story #503)
5962-
diff_type=request.diff_type,
5963-
author=request.author,
5964-
chunk_type=request.chunk_type,
5965-
)
5931+
semantic_results_raw = semantic_query_manager.query_user_repositories(
5932+
username=current_user.username,
5933+
query_text=request.query_text,
5934+
repository_alias=request.repository_alias,
5935+
limit=request.limit,
5936+
min_score=request.min_score,
5937+
file_extensions=request.file_extensions,
5938+
# Phase 1 parameters (Story #503)
5939+
exclude_language=request.exclude_language,
5940+
exclude_path=request.exclude_path,
5941+
accuracy=request.accuracy,
5942+
# Temporal parameters (Story #446)
5943+
time_range=request.time_range,
5944+
time_range_all=request.time_range_all,
5945+
at_commit=request.at_commit,
5946+
include_removed=request.include_removed,
5947+
show_evolution=request.show_evolution,
5948+
evolution_limit=request.evolution_limit,
5949+
# Phase 3 temporal filtering parameters (Story #503)
5950+
diff_type=request.diff_type,
5951+
author=request.author,
5952+
chunk_type=request.chunk_type,
59665953
)
59675954
semantic_results_list = [
59685955
QueryResultItem(**result)

src/code_indexer/server/auth/dependencies.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,9 @@ async def _hybrid_auth_impl(
549549
else:
550550
# Create User object from session
551551
if not user_manager:
552-
logger.error(f"Hybrid auth ({auth_type}): user_manager not initialized")
552+
logger.error(
553+
f"Hybrid auth ({auth_type}): user_manager not initialized"
554+
)
553555
raise HTTPException(
554556
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
555557
detail="User manager not initialized",

src/code_indexer/server/jobs/manager.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def __init__(
110110
from code_indexer.server.storage.sqlite_backends import (
111111
SyncJobsSqliteBackend,
112112
)
113+
113114
self._sqlite_backend = SyncJobsSqliteBackend(db_path)
114115

115116
self._jobs: Dict[str, SyncJob] = {}
@@ -446,8 +447,14 @@ def create_job(
446447
job_id=job_id,
447448
username=username,
448449
user_alias=user_alias,
449-
job_type=job_type.value if hasattr(job_type, "value") else str(job_type),
450-
status=initial_status.value if hasattr(initial_status, "value") else str(initial_status),
450+
job_type=(
451+
job_type.value if hasattr(job_type, "value") else str(job_type)
452+
),
453+
status=(
454+
initial_status.value
455+
if hasattr(initial_status, "value")
456+
else str(initial_status)
457+
),
451458
repository_url=repository_url,
452459
)
453460

@@ -557,7 +564,11 @@ def mark_job_completed(
557564
if self._use_sqlite and self._sqlite_backend is not None:
558565
self._sqlite_backend.update_job(
559566
job_id=job_id,
560-
status=job.status.value if hasattr(job.status, "value") else str(job.status),
567+
status=(
568+
job.status.value
569+
if hasattr(job.status, "value")
570+
else str(job.status)
571+
),
561572
completed_at=completed_at.isoformat(),
562573
progress=job.progress,
563574
error_message=error_message,
@@ -619,7 +630,9 @@ def cancel_job(self, job_id: str) -> None:
619630
self._sqlite_backend.update_job(
620631
job_id=job_id,
621632
status=JobStatus.CANCELLED.value,
622-
completed_at=job.completed_at.isoformat() if job.completed_at else None,
633+
completed_at=(
634+
job.completed_at.isoformat() if job.completed_at else None
635+
),
623636
)
624637

625638
# Persist changes (JSON file, no-op for SQLite)

src/code_indexer/server/models/auto_discovery.py

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,19 @@ class DiscoveredRepository(BaseModel):
1818
platform: Literal["gitlab", "github"] = Field(
1919
..., description="Platform source (gitlab or github)"
2020
)
21-
name: str = Field(
22-
..., min_length=1, description="Full path (e.g., group/project)"
23-
)
24-
description: Optional[str] = Field(
25-
None, description="Project description"
26-
)
27-
clone_url_https: str = Field(
28-
..., description="HTTPS clone URL"
29-
)
30-
clone_url_ssh: str = Field(
31-
..., description="SSH clone URL"
32-
)
33-
default_branch: str = Field(
34-
..., description="Default branch (main/master/etc)"
35-
)
21+
name: str = Field(..., min_length=1, description="Full path (e.g., group/project)")
22+
description: Optional[str] = Field(None, description="Project description")
23+
clone_url_https: str = Field(..., description="HTTPS clone URL")
24+
clone_url_ssh: str = Field(..., description="SSH clone URL")
25+
default_branch: str = Field(..., description="Default branch (main/master/etc)")
3626
last_commit_hash: Optional[str] = Field(
3727
None, description="Short hash of last commit"
3828
)
39-
last_commit_author: Optional[str] = Field(
40-
None, description="Author of last commit"
41-
)
29+
last_commit_author: Optional[str] = Field(None, description="Author of last commit")
4230
last_activity: Optional[datetime] = Field(
4331
None, description="Last activity timestamp"
4432
)
45-
is_private: bool = Field(
46-
..., description="Whether repository is private"
47-
)
33+
is_private: bool = Field(..., description="Whether repository is private")
4834

4935
@field_validator("clone_url_https")
5036
@classmethod
@@ -72,18 +58,10 @@ class RepositoryDiscoveryResult(BaseModel):
7258
total_count: int = Field(
7359
..., ge=0, description="Total number of repositories available"
7460
)
75-
page: int = Field(
76-
..., ge=1, description="Current page number (1-indexed)"
77-
)
78-
page_size: int = Field(
79-
..., ge=1, description="Number of items per page"
80-
)
81-
total_pages: int = Field(
82-
..., ge=0, description="Total number of pages"
83-
)
84-
platform: Literal["gitlab", "github"] = Field(
85-
..., description="Platform source"
86-
)
61+
page: int = Field(..., ge=1, description="Current page number (1-indexed)")
62+
page_size: int = Field(..., ge=1, description="Number of items per page")
63+
total_pages: int = Field(..., ge=0, description="Total number of pages")
64+
platform: Literal["gitlab", "github"] = Field(..., description="Platform source")
8765

8866

8967
class DiscoveryProviderError(BaseModel):
@@ -95,9 +73,5 @@ class DiscoveryProviderError(BaseModel):
9573
error_type: Literal["not_configured", "api_error", "auth_error", "timeout"] = Field(
9674
..., description="Type of error"
9775
)
98-
message: str = Field(
99-
..., description="Human-readable error message"
100-
)
101-
details: Optional[str] = Field(
102-
None, description="Additional error details"
103-
)
76+
message: str = Field(..., description="Human-readable error message")
77+
details: Optional[str] = Field(None, description="Additional error details")

src/code_indexer/server/multi/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
from .multi_result_aggregator import MultiResultAggregator
1414
from .multi_search_service import MultiSearchService
1515
from .models import MultiSearchRequest, MultiSearchResponse, MultiSearchMetadata
16-
from .scip_models import SCIPMultiRequest, SCIPMultiResponse, SCIPMultiMetadata, SCIPResult
16+
from .scip_models import (
17+
SCIPMultiRequest,
18+
SCIPMultiResponse,
19+
SCIPMultiMetadata,
20+
SCIPResult,
21+
)
1722
from .scip_multi_service import SCIPMultiService
1823

1924
__all__ = [

src/code_indexer/server/multi/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class MultiSearchMetadata(BaseModel):
5858
"""
5959

6060
total_results: int = Field(..., description="Total number of results")
61-
total_repos_searched: int = Field(..., description="Repositories successfully searched")
61+
total_repos_searched: int = Field(
62+
..., description="Repositories successfully searched"
63+
)
6264
execution_time_ms: int = Field(..., description="Execution time in milliseconds")
6365

6466

src/code_indexer/server/multi/multi_result_aggregator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def __init__(self, limit: int, min_score: Optional[float] = None):
3131
self.limit = limit
3232
self.min_score = min_score
3333

34-
def aggregate(self, repo_results: Dict[str, List[Dict[str, Any]]]) -> Dict[str, List[Dict[str, Any]]]:
34+
def aggregate(
35+
self, repo_results: Dict[str, List[Dict[str, Any]]]
36+
) -> Dict[str, List[Dict[str, Any]]]:
3537
"""
3638
Aggregate results in per-repository mode with optional score filtering.
3739

src/code_indexer/server/repositories/background_jobs.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,12 @@ def _persist_jobs_sqlite(self) -> None:
718718
self._sqlite_backend.update_job(
719719
job_id=job_id,
720720
status=job.status.value,
721-
started_at=job.started_at.isoformat() if job.started_at else None,
722-
completed_at=job.completed_at.isoformat() if job.completed_at else None,
721+
started_at=(
722+
job.started_at.isoformat() if job.started_at else None
723+
),
724+
completed_at=(
725+
job.completed_at.isoformat() if job.completed_at else None
726+
),
723727
result=job.result,
724728
error=job.error,
725729
progress=job.progress,
@@ -737,8 +741,12 @@ def _persist_jobs_sqlite(self) -> None:
737741
operation_type=job.operation_type,
738742
status=job.status.value,
739743
created_at=job.created_at.isoformat(),
740-
started_at=job.started_at.isoformat() if job.started_at else None,
741-
completed_at=job.completed_at.isoformat() if job.completed_at else None,
744+
started_at=(
745+
job.started_at.isoformat() if job.started_at else None
746+
),
747+
completed_at=(
748+
job.completed_at.isoformat() if job.completed_at else None
749+
),
742750
result=job.result,
743751
error=job.error,
744752
progress=job.progress,

src/code_indexer/server/repositories/golden_repo_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,9 +1741,9 @@ async def get_golden_repo_branches(
17411741
raise GoldenRepoError(f"Golden repository '{alias}' not found")
17421742

17431743
branch_service = GoldenRepoBranchService(self)
1744-
branches: List[
1745-
"GoldenRepoBranchInfo"
1746-
] = await branch_service.get_golden_repo_branches(alias)
1744+
branches: List["GoldenRepoBranchInfo"] = (
1745+
await branch_service.get_golden_repo_branches(alias)
1746+
)
17471747
return branches
17481748

17491749
def add_index_to_golden_repo(

src/code_indexer/server/services/claude_cli_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def __init__(self, api_key: Optional[str] = None, max_workers: int = 4):
5252
"""
5353
self._api_key = api_key
5454
self._max_workers = max_workers
55-
self._work_queue: "queue.Queue[Optional[Tuple[Path, Callable[[bool, str], None]]]]" = queue.Queue()
55+
self._work_queue: (
56+
"queue.Queue[Optional[Tuple[Path, Callable[[bool, str], None]]]]"
57+
) = queue.Queue()
5658
self._worker_threads: List[threading.Thread] = []
5759
self._shutdown_event = threading.Event()
5860
self._cli_available: Optional[bool] = None

0 commit comments

Comments
 (0)