Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ disable = ["R0801"]
extend-exclude = ["tests/profiles/syntax_error.py"]

[tool.ruff.lint]
extend-select = ["TID251", "UP006"]
extend-select = ["TID251", "UP006", "RUF100"]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
unittest = { msg = "use pytest instead of unittest" }
Expand Down
4 changes: 2 additions & 2 deletions scripts/generate_openapi_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def read_version_from_pyproject():
# it is not safe to just try to read version from pyproject.toml file directly
# the PDM tool itself is able to retrieve the version, even if the version
# is generated dynamically
completed = subprocess.run( # noqa: S603
["pdm", "show", "--version"], # noqa: S607
completed = subprocess.run(
["pdm", "show", "--version"],
capture_output=True,
check=True,
)
Expand Down
2 changes: 1 addition & 1 deletion src/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def check_llama_stack_model(self) -> Self:
if self.library_client_config_path is None:
# pylint: disable=line-too-long
raise ValueError(
"Llama stack library client mode is enabled but a configuration file path is not specified" # noqa: E501
"Llama stack library client mode is enabled but a configuration file path is not specified"
)
# the configuration file must exists and be regular readable file
checks.file_check(
Expand Down
4 changes: 2 additions & 2 deletions src/quota/quota_exceed_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def __init__(
else:
match subject_type:
case "u":
message = f"User {subject_id} has {available} tokens, but {needed} tokens are needed" # noqa: E501
message = f"User {subject_id} has {available} tokens, but {needed} tokens are needed"
case "c":
message = f"Cluster has {available} tokens, but {needed} tokens are needed"
case _:
message = f"Unknown subject {subject_id} has {available} tokens, but {needed} tokens are needed" # noqa: E501
message = f"Unknown subject {subject_id} has {available} tokens, but {needed} tokens are needed"

# call the base class constructor with the parameters it needs
super().__init__(message)
Expand Down
8 changes: 4 additions & 4 deletions src/quota/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@
updated_at timestamp with time zone,
PRIMARY KEY(user_id, provider, model)
);
""" # noqa: S105
"""

INIT_TOKEN_USAGE_FOR_USER = """
INSERT INTO token_usage (user_id, provider, model, input_tokens, output_tokens, updated_at)
VALUES (%s, %s, %s, 0, 0, %s)
""" # noqa: S105
"""

CONSUME_TOKENS_FOR_USER_SQLITE = """
INSERT INTO token_usage (user_id, provider, model, input_tokens, output_tokens, updated_at)
Expand All @@ -131,7 +131,7 @@
WHERE token_usage.user_id=:user_id
AND token_usage.provider=:provider
AND token_usage.model=:model
""" # noqa: E501
"""

CONSUME_TOKENS_FOR_USER_PG = """
INSERT INTO token_usage (user_id, provider, model, input_tokens, output_tokens, updated_at)
Expand All @@ -144,4 +144,4 @@
WHERE token_usage.user_id=%(user_id)s
AND token_usage.provider=%(provider)s
AND token_usage.model=%(model)s
""" # noqa: E501
"""
2 changes: 1 addition & 1 deletion tests/integration/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def read_version_from_pyproject() -> str:
# the PDM tool itself is able to retrieve the version, even if the version
# is generated dynamically
completed = subprocess.run(
["pdm", "show", "--version"], # noqa: S607
["pdm", "show", "--version"],
capture_output=True,
check=True,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Unit tests."""

from typing import Any
from configuration import configuration # noqa: F401
from configuration import configuration

config_dict: dict[str, Any] = {
"name": "test",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/app/endpoints/test_streaming_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@ def build_mcp_tool_call_side_effect(
) -> Any:
# Remove item from dict to simulate real behavior
# arguments parameter is required by function signature but unused here
_ = arguments # noqa: F841
_ = arguments
if output_index in mcp_call_items:
del mcp_call_items[output_index]
return mock_tool_call
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/app/test_routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from fastapi import FastAPI

from app.routers import include_routers # noqa:E402
from app.routers import include_routers

from app.endpoints import (
conversations_v2,
Expand All @@ -27,7 +27,7 @@
rlsapi_v1,
a2a,
query,
) # noqa:E402
)


class MockFastAPI(FastAPI):
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/utils/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ async def test_get_mcp_tools_with_mcp_headers(self, mocker: MockerFixture) -> No
async def test_get_mcp_tools_client_auth_no_mcp_headers(
self, mocker: MockerFixture
) -> None:
"""Test get_mcp_tools skips server when mcp_headers is None and server requires client auth.""" # noqa: E501
"""Test get_mcp_tools skips server when mcp_headers is None and server requires client auth."""
servers = [
ModelContextProtocolServer(
name="client-auth-server",
Expand Down Expand Up @@ -962,7 +962,7 @@ async def test_prepare_tools_with_mcp_servers(self, mocker: MockerFixture) -> No

@pytest.mark.asyncio
async def test_prepare_tools_api_status_error(self, mocker: MockerFixture) -> None:
"""Test prepare_tools raises HTTPException on API status error when fetching vector stores.""" # noqa: E501
"""Test prepare_tools raises HTTPException on API status error when fetching vector stores."""
mock_client = mocker.AsyncMock()
mock_client.vector_stores.list = mocker.AsyncMock(
side_effect=APIStatusError(
Expand Down Expand Up @@ -1198,7 +1198,7 @@ async def test_prepare_responses_params_create_conversation(
async def test_prepare_responses_params_connection_error_on_models(
self, mocker: MockerFixture
) -> None:
"""Test prepare_responses_params raises HTTPException on connection error when fetching models.""" # noqa: E501
"""Test prepare_responses_params raises HTTPException on connection error when fetching models."""
mock_client = mocker.AsyncMock()
mock_client.models.list = mocker.AsyncMock(
side_effect=APIConnectionError(
Expand All @@ -1219,7 +1219,7 @@ async def test_prepare_responses_params_connection_error_on_models(
async def test_prepare_responses_params_connection_error_on_conversation(
self, mocker: MockerFixture
) -> None:
"""Test prepare_responses_params raises HTTPException on connection error when creating conversation.""" # noqa: E501
"""Test prepare_responses_params raises HTTPException on connection error when creating conversation."""
mock_client = mocker.AsyncMock()
mock_model = mocker.Mock()
mock_model.id = "provider1/model1"
Expand Down Expand Up @@ -1248,7 +1248,7 @@ async def test_prepare_responses_params_connection_error_on_conversation(
async def test_prepare_responses_params_api_status_error_on_models(
self, mocker: MockerFixture
) -> None:
"""Test prepare_responses_params raises HTTPException on API status error when fetching models.""" # noqa: E501
"""Test prepare_responses_params raises HTTPException on API status error when fetching models."""
mock_client = mocker.AsyncMock()
mock_client.models.list = mocker.AsyncMock(
side_effect=APIStatusError(
Expand Down Expand Up @@ -1366,7 +1366,7 @@ async def test_prepare_responses_params_no_extra_headers_without_mcp_tools(
async def test_prepare_responses_params_api_status_error_on_conversation(
self, mocker: MockerFixture
) -> None:
"""Test prepare_responses_params raises HTTPException on API status error when creating conversation.""" # noqa: E501
"""Test prepare_responses_params raises HTTPException on API status error when creating conversation."""
mock_client = mocker.AsyncMock()
mock_model = mocker.Mock()
mock_model.id = "provider1/model1"
Expand Down
Loading