Skip to content

Commit 1b1eec6

Browse files
committed
chore: more backend formatting
1 parent 43dea15 commit 1b1eec6

File tree

13 files changed

+67
-57
lines changed

13 files changed

+67
-57
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v6
11-
- name: Set up Python
12-
uses: actions/setup-python@v6
13-
with:
14-
python-version: "3.13"
11+
1512
- name: Install uv
16-
run: curl -LsSf https://astral.sh/uv/install.sh | sh
17-
- name: Sync dependencies
13+
uses: astral-sh/setup-uv@v7
14+
15+
- name: Set up Python
16+
run: uv python install 3.13
17+
18+
- name: Install dependencies
1819
working-directory: backend
19-
run: uv sync
20+
run: uv sync --all-extras
21+
2022
- name: Check formatting
2123
working-directory: backend
2224
run: uv run ruff format --check .
2325

26+
- name: Lint
27+
working-directory: backend
28+
run: uv run ruff check .
29+
2430
frontend-format:
2531
runs-on: ubuntu-latest
2632
strategy:
@@ -31,15 +37,19 @@ jobs:
3137
- e2e_tests/tests_omni_light
3238
steps:
3339
- uses: actions/checkout@v6
40+
3441
- name: Set up Node.js
3542
uses: actions/setup-node@v6
3643
with:
3744
node-version: "20"
45+
3846
- name: Install pnpm
3947
run: npm install -g pnpm
48+
4049
- name: Install dependencies
4150
working-directory: ${{ matrix.working-dir }}
4251
run: pnpm install
52+
4353
- name: Check formatting and linting
4454
working-directory: ${{ matrix.working-dir }}
4555
run: pnpm check
@@ -48,32 +58,38 @@ jobs:
4858
runs-on: ubuntu-latest
4959
steps:
5060
- uses: actions/checkout@v6
51-
- name: Set up Python
52-
uses: actions/setup-python@v6
53-
with:
54-
python-version: "3.13"
61+
5562
- name: Install uv
56-
run: curl -LsSf https://astral.sh/uv/install.sh | sh
57-
- name: Sync dependencies
63+
uses: astral-sh/setup-uv@v7
64+
65+
- name: Set up Python
66+
run: uv python install 3.13
67+
68+
- name: Install dependencies
5869
working-directory: backend
59-
run: uv sync
70+
run: uv sync --all-extras
71+
6072
- name: Run tests
6173
working-directory: backend
62-
run: uv run pytest
74+
run: uv run pytest -v
6375

6476
frontend-unit:
6577
runs-on: ubuntu-latest
6678
steps:
6779
- uses: actions/checkout@v6
80+
6881
- name: Set up Node.js
6982
uses: actions/setup-node@v6
7083
with:
7184
node-version: "20"
85+
7286
- name: Install pnpm
7387
run: npm install -g pnpm
88+
7489
- name: Install dependencies
7590
working-directory: frontend_omni
7691
run: pnpm install
92+
7793
- name: Run unit tests
7894
working-directory: frontend_omni
7995
run: pnpm test
@@ -87,27 +103,27 @@ jobs:
87103
- e2e_tests/tests_omni_light
88104
steps:
89105
- uses: actions/checkout@v6
90-
- name: Set up Python
91-
uses: actions/setup-python@v6
92-
with:
93-
python-version: "3.13"
94-
- name: Install uv
95-
run: curl -LsSf https://astral.sh/uv/install.sh | sh
106+
96107
- name: Set up Node.js
97108
uses: actions/setup-node@v6
98109
with:
99110
node-version: "20"
111+
100112
- name: Install pnpm
101113
run: npm install -g pnpm
114+
102115
- name: Install dependencies for frontend
103116
working-directory: frontend_omni
104117
run: pnpm install
118+
105119
- name: Install dependencies for tests
106120
working-directory: ${{ matrix.working-dir }}
107121
run: pnpm install
122+
108123
- name: Install Playwright browsers
109124
working-directory: ${{ matrix.working-dir }}
110125
run: pnpm playwright install --with-deps
126+
111127
- name: Run Playwright tests
112128
working-directory: ${{ matrix.working-dir }}
113129
run: pnpm test

backend/src/modai/modules/chat/web_chat_router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from fastapi import APIRouter, Request, Body
1+
from fastapi import Request, Body
22
from fastapi.responses import StreamingResponse, JSONResponse
33
from typing import Any, Dict, cast
44
from modai.module import ModuleDependencies

backend/src/modai/modules/model_provider/central_router.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from modai.modules.model_provider.module import (
1212
ModelProviderResponse,
1313
ModelProviderModule,
14-
ModelResponse,
1514
Model,
1615
)
1716

backend/src/modai/modules/session/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import logging
99
from abc import ABC, abstractmethod
1010
from dataclasses import dataclass
11-
from typing import Any, Dict
11+
from typing import Any
1212

1313
from fastapi import Request, Response
1414
from modai.module import ModaiModule, ModuleDependencies

backend/src/modai/modules/user_settings/simple_user_settings_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This implementation delegates persistence to a UserSettingsStore module.
44
"""
55

6-
from typing import Any, Dict
6+
from typing import Any
77
from fastapi import Request, HTTPException
88

99
from modai.module import ModuleDependencies

backend/tests/abstract_model_provider_store_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ async def test_update_provider_with_duplicate_name_raises_exception(
199199
self, model_provider_store
200200
):
201201
"""Test that updating a provider to use an existing name raises an exception"""
202-
provider1 = await model_provider_store.add_provider(
202+
await model_provider_store.add_provider(
203203
name="Provider1", url="https://api1.com", properties={}
204204
)
205205
provider2 = await model_provider_store.add_provider(

backend/tests/test_authentication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import pytest
44
from unittest.mock import Mock, MagicMock, AsyncMock
55
from fastapi.testclient import TestClient
6-
from fastapi import FastAPI, Request, Response
6+
from fastapi import FastAPI
77

88
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
99
from modai.module import ModuleDependencies
1010
from modai.modules.authentication.password_authentication_module import (
1111
PasswordAuthenticationModule,
1212
)
13-
from modai.modules.session.module import SessionModule, Session
13+
from modai.modules.session.module import SessionModule
1414
from modai.modules.user_store.module import UserStore, User, UserCredentials
1515

1616

backend/tests/test_central_model_provider_router.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import sys
66
import os
77
import pytest
8-
from pathlib import Path
9-
from unittest.mock import AsyncMock, MagicMock
108
from fastapi.testclient import TestClient
119
from fastapi import FastAPI
1210

backend/tests/test_chat.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pytest_asyncio
77
from openai import AsyncOpenAI
88
from unittest.mock import Mock, AsyncMock
9-
from typing import AsyncGenerator
109

1110
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
1211
from modai.module import ModuleDependencies
@@ -70,7 +69,7 @@ async def openai_client(request):
7069
async def test_llm_generate_response():
7170
"""Test LLM generate_response method directly."""
7271
from fastapi import Request
73-
from unittest.mock import Mock, AsyncMock
72+
from unittest.mock import Mock
7473
from modai.modules.model_provider.module import (
7574
ModelProvidersListResponse,
7675
ModelProviderResponse,
@@ -139,7 +138,7 @@ async def test_llm_generate_response():
139138
async def test_llm_generate_response_streaming():
140139
"""Test LLM generate_response method directly for streaming."""
141140
from fastapi import Request
142-
from unittest.mock import Mock, AsyncMock
141+
from unittest.mock import Mock
143142
from modai.modules.model_provider.module import (
144143
ModelProvidersListResponse,
145144
ModelProviderResponse,
@@ -210,7 +209,7 @@ async def test_llm_generate_response_streaming():
210209
async def test_chat_responses_api(openai_client: AsyncOpenAI, request):
211210
"""Test chat responses API."""
212211

213-
client_type = request.node.callspec.params["openai_client"]
212+
request.node.callspec.params["openai_client"]
214213
model = "gpt-4o" # No backend_proxy
215214

216215
# Make the request
@@ -242,7 +241,7 @@ async def test_chat_responses_api(openai_client: AsyncOpenAI, request):
242241
async def test_chat_responses_api_streaming(openai_client: AsyncOpenAI, request):
243242
"""Test streaming chat responses API."""
244243

245-
client_type = request.node.callspec.params["openai_client"]
244+
request.node.callspec.params["openai_client"]
246245
model = "gpt-4o" # No backend_proxy
247246

248247
# Make the streaming request
@@ -351,7 +350,7 @@ async def test_chat_web_module_routing_streaming():
351350
async def test_openai_llm_invalid_model_format():
352351
"""Test OpenAILLMChatModule with invalid model format."""
353352
from fastapi import Request
354-
from unittest.mock import Mock, AsyncMock
353+
from unittest.mock import Mock
355354
from modai.modules.model_provider.module import (
356355
ModelProvidersListResponse,
357356
ModelProviderResponse,
@@ -403,7 +402,7 @@ async def test_openai_llm_invalid_model_format():
403402
async def test_openai_llm_provider_not_found():
404403
"""Test OpenAILLMChatModule when provider is not found."""
405404
from fastapi import Request
406-
from unittest.mock import Mock, AsyncMock
405+
from unittest.mock import Mock
407406
from modai.modules.model_provider.module import ModelProvidersListResponse
408407

409408
# Mock provider module with no providers

backend/tests/test_config_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_config_loader_valid_config(tmp_path: Path):
2222
loader = YamlConfigModule(ModuleDependencies(), {"config_path": str(config_file)})
2323
config = loader.get_config()
2424

25-
assert config["modules"]["health"]["enabled"] == True
25+
assert config["modules"]["health"]["enabled"]
2626

2727

2828
def test_config_loader_invalid_yaml(tmp_path: Path):

0 commit comments

Comments
 (0)