Skip to content

Commit bcda784

Browse files
authored
Merge pull request #1306 from tisnik/lcore-1438-short-returns
LCORE-1438: short returns
2 parents de8a85a + b41fd9c commit bcda784

10 files changed

Lines changed: 10 additions & 21 deletions

File tree

src/app/endpoints/health.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,14 @@ async def get_providers_health_statuses() -> list[ProviderHealthStatus]:
7575
providers = await client.providers.list()
7676
logger.debug("Found %d providers", len(providers))
7777

78-
health_results = [
78+
return [
7979
ProviderHealthStatus(
8080
provider_id=provider.provider_id,
8181
status=str(provider.health.get("status", "unknown")),
8282
message=str(provider.health.get("message", "")),
8383
)
8484
for provider in providers
8585
]
86-
return health_results
8786

8887
except APIConnectionError as e:
8988
logger.error("Failed to check providers health: %s", e)

src/app/endpoints/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def parse_llama_stack_model(model: Any) -> dict[str, Any]:
4949
if k not in ("provider_id", "provider_resource_id", "model_type")
5050
}
5151

52-
legacy_model = {
52+
return {
5353
"identifier": getattr(model, "id", ""),
5454
"metadata": metadata,
5555
"api_model_type": model_type,
@@ -58,7 +58,6 @@ def parse_llama_stack_model(model: Any) -> dict[str, Any]:
5858
"provider_resource_id": str(custom_metadata.get("provider_resource_id", "")),
5959
"model_type": model_type,
6060
}
61-
return legacy_model
6261

6362

6463
models_responses: dict[int | str, dict[str, Any]] = {

src/authorization/resolvers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ def _get_claims(auth: AuthTuple) -> dict[str, Any]:
148148
# No claims for guests
149149
return {}
150150

151-
jwt_claims = unsafe_get_claims(token)
152-
return jwt_claims
151+
return unsafe_get_claims(token)
153152

154153
@staticmethod
155154
def _evaluate_operator(

src/models/requests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ def validate_categories(
503503
if len(value) == 0:
504504
return None # Convert empty list to None for consistency
505505

506-
unique_categories = list(dict.fromkeys(value)) # don't lose ordering
507-
return unique_categories
506+
return list(dict.fromkeys(value)) # don't lose ordering
508507

509508
@model_validator(mode="after")
510509
def check_feedback_provided(self) -> Self:

src/utils/responses.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,8 +997,7 @@ async def select_model_for_responses(
997997
and user_conversation.last_used_model
998998
and user_conversation.last_used_provider
999999
):
1000-
model_id = f"{user_conversation.last_used_provider}/{user_conversation.last_used_model}"
1001-
return model_id
1000+
return f"{user_conversation.last_used_provider}/{user_conversation.last_used_model}"
10021001

10031002
# 2. Select default model from configuration
10041003
if configuration.inference is not None:

src/utils/tool_formatter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def format_tool_response(tool_dict: dict[str, Any]) -> dict[str, Any]:
3636
description = clean_description
3737

3838
# Extract only the required fields
39-
formatted_tool = {
39+
return {
4040
"identifier": tool_dict.get("identifier", ""),
4141
"description": description,
4242
"parameters": tool_dict.get("parameters", []),
@@ -46,8 +46,6 @@ def format_tool_response(tool_dict: dict[str, Any]) -> dict[str, Any]:
4646
"type": tool_dict.get("type", ""),
4747
}
4848

49-
return formatted_tool
50-
5149

5250
def extract_clean_description(description: str) -> str:
5351
"""

tests/benchmarks/data_generators.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,4 @@ def generate_topic_summary() -> str:
155155
],
156156
]
157157

158-
summary = " ".join([random.choice(yap) for yap in yaps]) + "."
159-
return summary
158+
return " ".join([random.choice(yap) for yap in yaps]) + "."

tests/e2e/utils/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,4 @@ def replace_placeholders(context: Context, text: str) -> str:
287287
"""
288288
result = text.replace("{MODEL}", context.default_model)
289289
result = result.replace("{PROVIDER}", context.default_provider)
290-
result = result.replace("{VECTOR_STORE_ID}", context.faiss_vector_store_id)
291-
return result
290+
return result.replace("{VECTOR_STORE_ID}", context.faiss_vector_store_id)

tests/unit/app/endpoints/test_query.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def create_dummy_request() -> Request:
4242
request (fastapi.Request): A Request constructed with a bare HTTP scope
4343
(type "http") for use in tests.
4444
"""
45-
req = Request(scope={"type": "http", "headers": []})
46-
return req
45+
return Request(scope={"type": "http", "headers": []})
4746

4847

4948
@pytest.fixture(name="setup_configuration")

tests/unit/utils/test_responses.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ def make_output_item(
9898
Returns:
9999
MockOutputItem: Mock object with type, role, and content attributes
100100
"""
101-
mock_item = MockOutputItem(item_type=item_type, role=role, content=content)
102-
return mock_item
101+
return MockOutputItem(item_type=item_type, role=role, content=content)
103102

104103

105104
def make_content_part(

0 commit comments

Comments
 (0)