Skip to content

Commit f26ef07

Browse files
fix errors
1 parent 61cdd38 commit f26ef07

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/server/routers/ingest.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
"""Ingest endpoint for the API."""
22

3-
from __future__ import annotations
4-
5-
from typing import TYPE_CHECKING
6-
from uuid import UUID # noqa: TC003 (typing-only-standard-library-import) needed for type checking (pydantic)
3+
from typing import Union
4+
from uuid import UUID
75

86
from fastapi import APIRouter, HTTPException, Request, status
97
from fastapi.responses import FileResponse, JSONResponse, RedirectResponse
108
from prometheus_client import Counter
119

1210
from gitingest.config import TMP_BASE_PATH
1311
from gitingest.utils.s3_utils import get_s3_url_for_ingest_id, is_s3_enabled
12+
from server.models import IngestRequest
1413
from server.routers_utils import COMMON_INGEST_RESPONSES, _perform_ingestion
1514
from server.server_config import MAX_DISPLAY_SIZE
1615
from server.server_utils import limiter
1716

18-
if TYPE_CHECKING:
19-
from server.models import IngestRequest
20-
2117
ingest_counter = Counter("gitingest_ingest_total", "Number of ingests", ["status", "url"])
2218

2319
router = APIRouter()
@@ -99,7 +95,9 @@ async def api_ingest_get(
9995

10096

10197
@router.get("/api/download/file/{ingest_id}", response_model=None)
102-
async def download_ingest(ingest_id: UUID) -> RedirectResponse | FileResponse:
98+
async def download_ingest(
99+
ingest_id: UUID,
100+
) -> Union[RedirectResponse, FileResponse]: # noqa: FA100 (future-rewritable-type-annotation) (pydantic)
103101
"""Download the first text file produced for an ingest ID.
104102
105103
**This endpoint retrieves the first ``*.txt`` file produced during the ingestion process**

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from __future__ import annotations
88

99
import json
10+
import uuid
1011
from pathlib import Path
1112
from typing import TYPE_CHECKING, Any, Callable, Dict
1213
from unittest.mock import AsyncMock
@@ -41,7 +42,7 @@ def sample_query() -> IngestionQuery:
4142
repo_name="test_repo",
4243
local_path=Path("/tmp/test_repo").resolve(),
4344
slug="test_user/test_repo",
44-
id="id",
45+
id=uuid.uuid4(),
4546
branch="main",
4647
max_file_size=1_000_000,
4748
ignore_patterns={"*.pyc", "__pycache__", ".git"},

tests/test_flow_integration.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def test_remote_repository_analysis(request: pytest.FixtureRequest) -> Non
5050
client = request.getfixturevalue("test_client")
5151
form_data = {
5252
"input_text": "https://github.com/octocat/Hello-World",
53-
"max_file_size": "243",
53+
"max_file_size": 243,
5454
"pattern_type": "exclude",
5555
"pattern": "",
5656
"token": "",
@@ -75,7 +75,7 @@ async def test_invalid_repository_url(request: pytest.FixtureRequest) -> None:
7575
client = request.getfixturevalue("test_client")
7676
form_data = {
7777
"input_text": "https://github.com/nonexistent/repo",
78-
"max_file_size": "243",
78+
"max_file_size": 243,
7979
"pattern_type": "exclude",
8080
"pattern": "",
8181
"token": "",
@@ -97,7 +97,7 @@ async def test_large_repository(request: pytest.FixtureRequest) -> None:
9797
# TODO: ingesting a large repo take too much time (eg: godotengine/godot repository)
9898
form_data = {
9999
"input_text": "https://github.com/octocat/hello-world",
100-
"max_file_size": "10",
100+
"max_file_size": 10,
101101
"pattern_type": "exclude",
102102
"pattern": "",
103103
"token": "",
@@ -122,7 +122,7 @@ async def test_concurrent_requests(request: pytest.FixtureRequest) -> None:
122122
def make_request() -> None:
123123
form_data = {
124124
"input_text": "https://github.com/octocat/hello-world",
125-
"max_file_size": "243",
125+
"max_file_size": 243,
126126
"pattern_type": "exclude",
127127
"pattern": "",
128128
"token": "",
@@ -149,7 +149,7 @@ async def test_large_file_handling(request: pytest.FixtureRequest) -> None:
149149
client = request.getfixturevalue("test_client")
150150
form_data = {
151151
"input_text": "https://github.com/octocat/Hello-World",
152-
"max_file_size": "1",
152+
"max_file_size": 1,
153153
"pattern_type": "exclude",
154154
"pattern": "",
155155
"token": "",
@@ -172,7 +172,7 @@ async def test_repository_with_patterns(request: pytest.FixtureRequest) -> None:
172172
client = request.getfixturevalue("test_client")
173173
form_data = {
174174
"input_text": "https://github.com/octocat/Hello-World",
175-
"max_file_size": "243",
175+
"max_file_size": 243,
176176
"pattern_type": "include",
177177
"pattern": "*.md",
178178
"token": "",

0 commit comments

Comments
 (0)