Skip to content

Commit 51efe00

Browse files
Ran pre-commit on cevatkerim's's branch and fixed type hints for CI to pass
1 parent 60e6b90 commit 51efe00

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ By default, this won't write a file but can be enabled with the `output` argumen
6969

7070
You can access repositories directly via URL:
7171

72-
```
72+
```plaintext
7373
# Basic repository access
7474
https://gitingest.com/user/repo
7575

src/process_query.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from typing import Union
21
from fastapi import Request
32
from fastapi.templating import Jinja2Templates
43
from starlette.templating import _TemplateResponse
@@ -19,8 +18,8 @@ async def process_query(
1918
pattern_type: str = "exclude",
2019
pattern: str = "",
2120
is_index: bool = False,
22-
raw_response: bool = False
23-
) -> Union[_TemplateResponse, tuple[str, str, str]]:
21+
raw_response: bool = False,
22+
) -> _TemplateResponse | tuple[str, str, str]:
2423
"""
2524
Process query and return template response or raw data tuple.
2625

src/routers/dynamic.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import typing
2+
13
from fastapi import APIRouter, Form, Request
24
from fastapi.responses import HTMLResponse, Response
35
from fastapi.templating import Jinja2Templates
@@ -8,6 +10,7 @@
810
router = APIRouter()
911
templates = Jinja2Templates(directory="templates")
1012

13+
1114
@router.get("/extract/{full_path:path}", response_model=None)
1215
async def extract_content(
1316
request: Request,
@@ -20,22 +23,24 @@ async def extract_content(
2023
pattern_type = query_params.get("pattern_type", "exclude")
2124
pattern = query_params.get("pattern", "")
2225

23-
result_summary, tree, content = await process_query(
26+
processed_query = await process_query(
2427
request,
2528
input_text=f"https://github.com/{full_path}",
2629
slider_position=max_file_size,
2730
pattern_type=pattern_type,
2831
pattern=pattern,
2932
is_index=False,
30-
raw_response=True
33+
raw_response=True,
3134
)
32-
35+
36+
result_summary, tree, content = typing.cast(tuple[str, str, str], processed_query)
37+
3338
response_parts = []
3439
if summary:
3540
response_parts.append(f"Summary:\n{result_summary}\n")
3641
response_parts.append(f"Tree:\n{tree}\n")
3742
response_parts.append(f"Content:\n{content}")
38-
43+
3944
return Response(content="\n".join(response_parts), media_type="text/plain")
4045
except Exception as e:
4146
return Response(
@@ -44,6 +49,7 @@ async def extract_content(
4449
status_code=500,
4550
)
4651

52+
4753
@router.get("/{full_path:path}")
4854
async def catch_all(request: Request, full_path: str) -> HTMLResponse:
4955
"""
@@ -84,7 +90,7 @@ async def process_catch_all(
8490
max_file_size: int = Form(...),
8591
pattern_type: str = Form(...),
8692
pattern: str = Form(...),
87-
) -> HTMLResponse:
93+
) -> HTMLResponse | tuple[str, str, str]:
8894
"""
8995
Processes the form submission with user input for query parameters.
9096

src/routers/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def index_post(
4747
max_file_size: int = Form(...),
4848
pattern_type: str = Form(...),
4949
pattern: str = Form(...),
50-
) -> HTMLResponse:
50+
) -> HTMLResponse | tuple[str, str, str]:
5151
"""
5252
Processes the form submission with user input for query parameters.
5353

0 commit comments

Comments
 (0)