[chore] run full pre-commit (#8104)

This commit is contained in:
Engel Nyst
2025-04-27 08:43:26 +02:00
committed by GitHub
parent 8a5c6d3bef
commit 70f469b0c1
17 changed files with 63 additions and 69 deletions

View File

@@ -35,6 +35,10 @@ export enum I18nKey {
CONVERSATION$START_NEW = "CONVERSATION$START_NEW",
ACCOUNT_SETTINGS$TITLE = "ACCOUNT_SETTINGS$TITLE",
WORKSPACE$TERMINAL_TAB_LABEL = "WORKSPACE$TERMINAL_TAB_LABEL",
WORKSPACE$BROWSER_TAB_LABEL = "WORKSPACE$BROWSER_TAB_LABEL",
WORKSPACE$JUPYTER_TAB_LABEL = "WORKSPACE$JUPYTER_TAB_LABEL",
WORKSPACE$CODE_EDITOR_TAB_LABEL = "WORKSPACE$CODE_EDITOR_TAB_LABEL",
WORKSPACE$TITLE = "WORKSPACE$TITLE",
TERMINAL$WAITING_FOR_CLIENT = "TERMINAL$WAITING_FOR_CLIENT",
CODE_EDITOR$FILE_SAVED_SUCCESSFULLY = "CODE_EDITOR$FILE_SAVED_SUCCESSFULLY",
CODE_EDITOR$SAVING_LABEL = "CODE_EDITOR$SAVING_LABEL",
@@ -281,6 +285,7 @@ export enum I18nKey {
BUTTON$CREATE = "BUTTON$CREATE",
BUTTON$DELETE = "BUTTON$DELETE",
BUTTON$COPY_TO_CLIPBOARD = "BUTTON$COPY_TO_CLIPBOARD",
BUTTON$REFRESH = "BUTTON$REFRESH",
ERROR$REQUIRED_FIELD = "ERROR$REQUIRED_FIELD",
PLANNER$EMPTY_MESSAGE = "PLANNER$EMPTY_MESSAGE",
FEEDBACK$PUBLIC_LABEL = "FEEDBACK$PUBLIC_LABEL",

View File

@@ -5,7 +5,6 @@ from typing import Any
from pydantic import BaseModel
from openhands.core.logger import openhands_logger as logger
from openhands.events import Event, EventSource
from openhands.events.serialization.action import action_from_dict
from openhands.events.serialization.observation import observation_from_dict

View File

@@ -1,5 +1,6 @@
import json
import os
from datetime import datetime
from typing import Any
import httpx
@@ -18,8 +19,6 @@ from openhands.integrations.service_types import (
)
from openhands.server.types import AppMode
from openhands.utils.import_utils import get_impl
from datetime import datetime
class GitHubService(BaseGitService, GitService):
@@ -159,12 +158,9 @@ class GitHubService(BaseGitService, GitService):
return repos[:max_repos] # Trim to max_repos if needed
def parse_pushed_at_date(self, repo):
ts = repo.get("pushed_at")
return datetime.strptime(ts, "%Y-%m-%dT%H:%M:%SZ") if ts else datetime.min
ts = repo.get('pushed_at')
return datetime.strptime(ts, '%Y-%m-%dT%H:%M:%SZ') if ts else datetime.min
async def get_repositories(self, sort: str, app_mode: AppMode) -> list[Repository]:
MAX_REPOS = 1000
@@ -193,10 +189,8 @@ class GitHubService(BaseGitService, GitService):
if len(all_repos) >= MAX_REPOS:
break
if sort == "pushed":
all_repos.sort(
key=self.parse_pushed_at_date, reverse=True
)
if sort == 'pushed':
all_repos.sort(key=self.parse_pushed_at_date, reverse=True)
else:
# Original behavior for non-SaaS mode
params = {'per_page': str(PER_PAGE), 'sort': sort}
@@ -205,7 +199,6 @@ class GitHubService(BaseGitService, GitService):
# Fetch user repositories
all_repos = await self._fetch_paginated_repos(url, params, MAX_REPOS)
# Convert to Repository objects
return [
Repository(

View File

@@ -108,7 +108,9 @@ class GitLabService(BaseGitService, GitService):
except httpx.HTTPError as e:
raise self.handle_http_error(e)
async def execute_graphql_query(self, query: str, variables: dict[str, Any] = {}) -> Any:
async def execute_graphql_query(
self, query: str, variables: dict[str, Any]|None = None
) -> Any:
"""
Execute a GraphQL query against the GitLab GraphQL API
@@ -119,6 +121,8 @@ class GitLabService(BaseGitService, GitService):
Returns:
The data portion of the GraphQL response
"""
if variables is None:
variables = {}
try:
async with httpx.AsyncClient() as client:
gitlab_headers = await self._get_gitlab_headers()
@@ -345,22 +349,22 @@ class GitLabService(BaseGitService, GitService):
)
# Get assigned issues using REST API
url = f"{self.BASE_URL}/issues"
url = f'{self.BASE_URL}/issues'
params = {
"assignee_username": username,
"state": "opened",
"scope": "assigned_to_me"
'assignee_username': username,
'state': 'opened',
'scope': 'assigned_to_me',
}
issues_response, _ = await self._make_request(
method=RequestMethod.GET,
url=url,
params=params
method=RequestMethod.GET, url=url, params=params
)
# Process issues
for issue in issues_response:
repo_name = issue.get('references', {}).get('full', '').split('#')[0].strip()
repo_name = (
issue.get('references', {}).get('full', '').split('#')[0].strip()
)
issue_number = issue.get('iid')
title = issue.get('title', '')

View File

@@ -20,7 +20,9 @@ class ServerConfig(ServerConfigInterface):
)
conversation_manager_class: str = 'openhands.server.conversation_manager.standalone_conversation_manager.StandaloneConversationManager'
monitoring_listener_class: str = 'openhands.server.monitoring.MonitoringListener'
user_auth_class: str = 'openhands.server.user_auth.default_user_auth.DefaultUserAuth'
user_auth_class: str = (
'openhands.server.user_auth.default_user_auth.DefaultUserAuth'
)
def verify_config(self):
if self.config_cls:

View File

@@ -234,7 +234,7 @@ async def git_diff(
request: Request,
path: str,
conversation_id: str,
conversation_store = Depends(get_conversation_store),
conversation_store=Depends(get_conversation_store),
):
runtime: Runtime = request.state.conversation.runtime

View File

@@ -2,11 +2,9 @@ from fastapi import APIRouter, Depends, status
from fastapi.responses import JSONResponse
from pydantic import SecretStr
from openhands.integrations.github.github_service import GithubServiceImpl
from openhands.integrations.provider import (
PROVIDER_TOKEN_TYPE,
ProviderHandler,
ProviderType,
)
from openhands.integrations.service_types import (
AuthenticationError,

View File

@@ -344,9 +344,7 @@ async def update_conversation(
title: str = Body(embed=True),
user_id: str | None = Depends(get_user_id),
) -> bool:
conversation_store = await ConversationStoreImpl.get_instance(
config, user_id
)
conversation_store = await ConversationStoreImpl.get_instance(config, user_id)
metadata = await conversation_store.get_metadata(conversation_id)
if not metadata:
return False
@@ -369,9 +367,7 @@ async def delete_conversation(
conversation_id: str,
user_id: str | None = Depends(get_user_id),
) -> bool:
conversation_store = await ConversationStoreImpl.get_instance(
config, user_id
)
conversation_store = await ConversationStoreImpl.get_instance(config, user_id)
try:
await conversation_store.get_metadata(conversation_id)
except FileNotFoundError:

View File

@@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends, Request, status
from fastapi import APIRouter, Depends, status
from fastapi.responses import JSONResponse
from pydantic import SecretStr
@@ -17,8 +17,7 @@ from openhands.server.settings import (
POSTSettingsModel,
Settings,
)
from openhands.server.shared import SettingsStoreImpl, config, server_config
from openhands.server.types import AppMode
from openhands.server.shared import config
from openhands.server.user_auth import (
get_provider_tokens,
get_user_id,
@@ -59,7 +58,8 @@ async def load_settings(
settings_with_token_data = GETSettingsModel(
**settings.model_dump(exclude='secrets_store'),
llm_api_key_set=settings.llm_api_key is not None and bool(settings.llm_api_key),
llm_api_key_set=settings.llm_api_key is not None
and bool(settings.llm_api_key),
provider_tokens_set=provider_tokens_set,
)
settings_with_token_data.llm_api_key = None
@@ -211,9 +211,7 @@ async def reset_settings() -> JSONResponse:
"""
Resets user settings. (Deprecated)
"""
logger.warning(
f"Deprecated endpoint /api/reset-settings called by user"
)
logger.warning('Deprecated endpoint /api/reset-settings called by user')
return JSONResponse(
status_code=status.HTTP_410_GONE,
content={'error': 'Reset settings functionality has been removed.'},

View File

@@ -1,6 +1,5 @@
from __future__ import annotations
import os
from abc import ABC, abstractmethod
from fastapi import Request