mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
chore(lint): Apply comprehensive linting and formatting fixes (#10287)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -191,8 +191,7 @@ class BitBucketService(BaseGitService, GitService, InstallationsService):
|
||||
def _parse_repository(
|
||||
self, repo: dict, link_header: str | None = None
|
||||
) -> Repository:
|
||||
"""
|
||||
Parse a Bitbucket API repository response into a Repository object.
|
||||
"""Parse a Bitbucket API repository response into a Repository object.
|
||||
|
||||
Args:
|
||||
repo: Repository data from Bitbucket API
|
||||
@@ -201,7 +200,6 @@ class BitBucketService(BaseGitService, GitService, InstallationsService):
|
||||
Returns:
|
||||
Repository object
|
||||
"""
|
||||
|
||||
repo_id = repo.get('uuid', '')
|
||||
|
||||
workspace_slug = repo.get('workspace', {}).get('slug', '')
|
||||
@@ -292,8 +290,7 @@ class BitBucketService(BaseGitService, GitService, InstallationsService):
|
||||
async def _fetch_paginated_data(
|
||||
self, url: str, params: dict, max_items: int
|
||||
) -> list[dict]:
|
||||
"""
|
||||
Fetch data with pagination support for Bitbucket API.
|
||||
"""Fetch data with pagination support for Bitbucket API.
|
||||
|
||||
Args:
|
||||
url: The API endpoint URL
|
||||
|
||||
@@ -186,8 +186,7 @@ class GitHubService(BaseGitService, GitService, InstallationsService):
|
||||
async def _fetch_paginated_repos(
|
||||
self, url: str, params: dict, max_repos: int, extract_key: str | None = None
|
||||
) -> list[dict]:
|
||||
"""
|
||||
Fetch repositories with pagination support.
|
||||
"""Fetch repositories with pagination support.
|
||||
|
||||
Args:
|
||||
url: The API endpoint URL
|
||||
@@ -228,8 +227,7 @@ class GitHubService(BaseGitService, GitService, InstallationsService):
|
||||
def _parse_repository(
|
||||
self, repo: dict, link_header: str | None = None
|
||||
) -> Repository:
|
||||
"""
|
||||
Parse a GitHub API repository response into a Repository object.
|
||||
"""Parse a GitHub API repository response into a Repository object.
|
||||
|
||||
Args:
|
||||
repo: Repository data from GitHub API
|
||||
@@ -550,8 +548,7 @@ class GitHubService(BaseGitService, GitService, InstallationsService):
|
||||
draft: bool = True,
|
||||
labels: list[str] | None = None,
|
||||
) -> str:
|
||||
"""
|
||||
Creates a PR using user credentials
|
||||
"""Creates a PR using user credentials
|
||||
|
||||
Args:
|
||||
repo_name: The full name of the repository (owner/repo)
|
||||
@@ -566,7 +563,6 @@ class GitHubService(BaseGitService, GitService, InstallationsService):
|
||||
- PR URL when successful
|
||||
- Error message when unsuccessful
|
||||
"""
|
||||
|
||||
url = f'{self.BASE_URL}/repos/{repo_name}/pulls'
|
||||
|
||||
# Set default body if none provided
|
||||
|
||||
@@ -71,9 +71,7 @@ class GitLabService(BaseGitService, GitService):
|
||||
return ProviderType.GITLAB.value
|
||||
|
||||
async def _get_gitlab_headers(self) -> dict[str, Any]:
|
||||
"""
|
||||
Retrieve the GitLab Token to construct the headers
|
||||
"""
|
||||
"""Retrieve the GitLab Token to construct the headers"""
|
||||
if not self.token:
|
||||
latest_token = await self.get_latest_token()
|
||||
if latest_token:
|
||||
@@ -173,8 +171,7 @@ class GitLabService(BaseGitService, GitService):
|
||||
async def execute_graphql_query(
|
||||
self, query: str, variables: dict[str, Any] | None = None
|
||||
) -> Any:
|
||||
"""
|
||||
Execute a GraphQL query against the GitLab GraphQL API
|
||||
"""Execute a GraphQL query against the GitLab GraphQL API
|
||||
|
||||
Args:
|
||||
query: The GraphQL query string
|
||||
@@ -244,8 +241,7 @@ class GitLabService(BaseGitService, GitService):
|
||||
def _parse_repository(
|
||||
self, repo: dict, link_header: str | None = None
|
||||
) -> Repository:
|
||||
"""
|
||||
Parse a GitLab API project response into a Repository object.
|
||||
"""Parse a GitLab API project response into a Repository object.
|
||||
|
||||
Args:
|
||||
repo: Project data from GitLab API
|
||||
@@ -269,8 +265,7 @@ class GitLabService(BaseGitService, GitService):
|
||||
)
|
||||
|
||||
def _parse_gitlab_url(self, url: str) -> str | None:
|
||||
"""
|
||||
Parse a GitLab URL to extract the repository path.
|
||||
"""Parse a GitLab URL to extract the repository path.
|
||||
|
||||
Expected format: https://{domain}/{group}/{possibly_subgroup}/{repo}
|
||||
Returns the full path from group onwards (e.g., 'group/subgroup/repo' or 'group/repo')
|
||||
@@ -588,8 +583,7 @@ class GitLabService(BaseGitService, GitService):
|
||||
description: str | None = None,
|
||||
labels: list[str] | None = None,
|
||||
) -> str:
|
||||
"""
|
||||
Creates a merge request in GitLab
|
||||
"""Creates a merge request in GitLab
|
||||
|
||||
Args:
|
||||
id: The ID or URL-encoded path of the project
|
||||
@@ -603,7 +597,6 @@ class GitLabService(BaseGitService, GitService):
|
||||
- MR URL when successful
|
||||
- Error message when unsuccessful
|
||||
"""
|
||||
|
||||
# Convert string ID to URL-encoded path if needed
|
||||
project_id = str(id).replace('/', '%2F') if isinstance(id, str) else id
|
||||
url = f'{self.BASE_URL}/projects/{project_id}/merge_requests'
|
||||
|
||||
@@ -191,10 +191,7 @@ class ProviderHandler:
|
||||
per_page: int | None,
|
||||
installation_id: str | None,
|
||||
) -> list[Repository]:
|
||||
"""
|
||||
Get repositories from providers
|
||||
"""
|
||||
|
||||
"""Get repositories from providers"""
|
||||
"""
|
||||
Get repositories from providers
|
||||
"""
|
||||
@@ -226,9 +223,7 @@ class ProviderHandler:
|
||||
return all_repos
|
||||
|
||||
async def get_suggested_tasks(self) -> list[SuggestedTask]:
|
||||
"""
|
||||
Get suggested tasks from providers
|
||||
"""
|
||||
"""Get suggested tasks from providers"""
|
||||
tasks: list[SuggestedTask] = []
|
||||
for provider in self.provider_tokens:
|
||||
try:
|
||||
@@ -303,8 +298,7 @@ class ProviderHandler:
|
||||
event_stream: EventStream,
|
||||
env_vars: dict[ProviderType, SecretStr] | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
This ensures that the latest provider tokens are masked from the event stream
|
||||
"""This ensures that the latest provider tokens are masked from the event stream
|
||||
It is called when the provider tokens are first initialized in the runtime or when tokens are re-exported with the latest working ones
|
||||
|
||||
Args:
|
||||
@@ -320,8 +314,7 @@ class ProviderHandler:
|
||||
def expose_env_vars(
|
||||
self, env_secrets: dict[ProviderType, SecretStr]
|
||||
) -> dict[str, str]:
|
||||
"""
|
||||
Return string values instead of typed values for environment secrets
|
||||
"""Return string values instead of typed values for environment secrets
|
||||
Called just before exporting secrets to runtime, or setting secrets in the event stream
|
||||
"""
|
||||
exposed_envs = {}
|
||||
@@ -353,8 +346,7 @@ class ProviderHandler:
|
||||
providers: list[ProviderType] | None = None,
|
||||
get_latest: bool = False,
|
||||
) -> dict[ProviderType, SecretStr] | dict[str, str]:
|
||||
"""
|
||||
Retrieves the provider tokens from ProviderHandler object
|
||||
"""Retrieves the provider tokens from ProviderHandler object
|
||||
This is used when initializing/exporting new provider tokens in the runtime
|
||||
|
||||
Args:
|
||||
@@ -362,7 +354,6 @@ class ProviderHandler:
|
||||
providers: Return provider tokens for the list passed in, otherwise return all available providers
|
||||
get_latest: Get the latest working token for the providers if True, otherwise get the existing ones
|
||||
"""
|
||||
|
||||
if not self.provider_tokens:
|
||||
return {}
|
||||
|
||||
@@ -393,11 +384,9 @@ class ProviderHandler:
|
||||
def check_cmd_action_for_provider_token_ref(
|
||||
cls, event: Action
|
||||
) -> list[ProviderType]:
|
||||
"""
|
||||
Detect if agent run action is using a provider token (e.g $GITHUB_TOKEN)
|
||||
"""Detect if agent run action is using a provider token (e.g $GITHUB_TOKEN)
|
||||
Returns a list of providers which are called by the agent
|
||||
"""
|
||||
|
||||
if not isinstance(event, CmdRunAction):
|
||||
return []
|
||||
|
||||
@@ -410,9 +399,7 @@ class ProviderHandler:
|
||||
|
||||
@classmethod
|
||||
def get_provider_env_key(cls, provider: ProviderType) -> str:
|
||||
"""
|
||||
Map ProviderType value to the environment variable name in the runtime
|
||||
"""
|
||||
"""Map ProviderType value to the environment variable name in the runtime"""
|
||||
return f'{provider.value}_token'.lower()
|
||||
|
||||
async def verify_repo_provider(
|
||||
@@ -443,8 +430,7 @@ class ProviderHandler:
|
||||
async def get_branches(
|
||||
self, repository: str, specified_provider: ProviderType | None = None
|
||||
) -> list[Branch]:
|
||||
"""
|
||||
Get branches for a repository
|
||||
"""Get branches for a repository
|
||||
|
||||
Args:
|
||||
repository: The repository name
|
||||
|
||||
@@ -10,8 +10,7 @@ from openhands.integrations.provider import ProviderType
|
||||
async def validate_provider_token(
|
||||
token: SecretStr, base_domain: str | None = None
|
||||
) -> ProviderType | None:
|
||||
"""
|
||||
Determine whether a token is for GitHub, GitLab, or Bitbucket by attempting to get user info
|
||||
"""Determine whether a token is for GitHub, GitLab, or Bitbucket by attempting to get user info
|
||||
from the services.
|
||||
|
||||
Args:
|
||||
|
||||
Reference in New Issue
Block a user