From f63cd426b971e78cb09fef4beb80de03e616663f Mon Sep 17 00:00:00 2001 From: maco Date: Sun, 20 Sep 2026 06:14:44 +0000 Subject: [PATCH] style: apply ruff format so Python CI passes --- backend/open_webui/env.py | 4 +++- backend/open_webui/utils/access_control/files.py | 4 +--- backend/open_webui/utils/middleware.py | 14 +++++++++----- backend/open_webui/utils/skills.py | 5 ++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 68c4272872..ac5883700b 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -1048,7 +1048,9 @@ ENABLE_API_OUTLET_FILTERS = os.getenv('ENABLE_API_OUTLET_FILTERS', 'True').lower # Opt in to CPython's in-place string append optimization for streamed responses. # Off by default for a staged rollout. Only a host already out of memory can lose # text here; the default path (a full copy per chunk) raises there too. -ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND = os.getenv('ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND', 'False').lower() == 'true' +ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND = ( + os.getenv('ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND', 'False').lower() == 'true' +) # When enabled, uses a hardcoded extension-to-MIME dictionary as a last-resort # fallback when both mimetypes.guess_type() and file.meta.content_type fail to diff --git a/backend/open_webui/utils/access_control/files.py b/backend/open_webui/utils/access_control/files.py index 66cf3d4484..f4859acb95 100644 --- a/backend/open_webui/utils/access_control/files.py +++ b/backend/open_webui/utils/access_control/files.py @@ -84,9 +84,7 @@ async def has_access_to_file( # Check if the file is directly attached to a shared workspace model (per the ownership # note above, model write is conferred only for files the model owner owns). - model_owners = await Models.get_model_owner_ids_by_file_id( - file.id, db=db, include_background=access_type == 'read' - ) + model_owners = await Models.get_model_owner_ids_by_file_id(file.id, db=db, include_background=access_type == 'read') if access_type != 'read': model_owners = {model_id: owner_id for model_id, owner_id in model_owners.items() if owner_id == file.user_id} if user.id in model_owners.values(): diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index cf4f001d71..56cfcf7b03 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2232,7 +2232,9 @@ async def load_messages_from_db(chat_id: str, message_id: str) -> Optional[list[ return [ {k: v for k, v in msg.items() if k in MESSAGE_REPLAY_KEYS} for msg in db_messages - if not (msg.get('role') == 'assistant' and msg.get('error') and not msg.get('content') and not msg.get('output')) + if not ( + msg.get('role') == 'assistant' and msg.get('error') and not msg.get('content') and not msg.get('output') + ) ] @@ -2330,8 +2332,6 @@ def sanitize_tool_pairs(messages: list[dict]) -> list[dict]: return sanitized - - async def connect_mcp_server( request, server_id: str, @@ -2844,7 +2844,9 @@ async def process_chat_payload(request, form_data, user, metadata, model): ) terminal_request = ( - await get_terminal_request_info(request, user, metadata, extra_params) if terminal_id or terminal_skill_ids else None + await get_terminal_request_info(request, user, metadata, extra_params) + if terminal_id or terminal_skill_ids + else None ) listed_terminal_skills = [] @@ -2872,7 +2874,9 @@ async def process_chat_payload(request, form_data, user, metadata, model): sid = skill['id'] if sid in mentioned_skill_ids or not use_builtin_tools: skill_name = unquote(sid.removeprefix(terminal_skill_prefix)) - loaded = await get_terminal_skill(request, user.model_dump(), metadata, skill_name, extra_params) + loaded = await get_terminal_skill( + request, user.model_dump(), metadata, skill_name, extra_params + ) if loaded: form_data['messages'] = add_or_update_system_message( format_terminal_skill_context(loaded), diff --git a/backend/open_webui/utils/skills.py b/backend/open_webui/utils/skills.py index 5adc071986..1cbe439dc1 100644 --- a/backend/open_webui/utils/skills.py +++ b/backend/open_webui/utils/skills.py @@ -32,7 +32,7 @@ def extract_skill_ids_from_messages(messages: list[dict]) -> set[str]: SKILL_MENTION_STRIP_RE = re.compile(rf'<(?:\$({SKILL_ID_RE})(?:\|([^>]*))?|/({SKILL_ID_RE})\|([^>]*))>') -SKILLS_CREATE_RE = re.compile(r"^/skills:create(?:\s+(.*))?$", re.IGNORECASE | re.DOTALL) +SKILLS_CREATE_RE = re.compile(r'^/skills:create(?:\s+(.*))?$', re.IGNORECASE | re.DOTALL) OPEN_WEBUI_SKILL_AUTHORING_STANDARDS = """\ Follow the Open WebUI skill-authoring standards: @@ -126,8 +126,7 @@ def has_prior_real_chat_content(messages: list[dict]) -> bool: len(messages), ) return any( - message.get('role') == 'user' and _message_has_real_content(message) - for message in messages[:last_user_idx] + message.get('role') == 'user' and _message_has_real_content(message) for message in messages[:last_user_idx] )