mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
chore - Add pydantic lib to type checking (#9086)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -72,7 +72,9 @@ class GitHubService(BaseGitService, GitService):
|
||||
async def _get_github_headers(self) -> dict:
|
||||
"""Retrieve the GH Token from settings store to construct the headers."""
|
||||
if not self.token:
|
||||
self.token = await self.get_latest_token()
|
||||
latest_token = await self.get_latest_token()
|
||||
if latest_token:
|
||||
self.token = latest_token
|
||||
|
||||
return {
|
||||
'Authorization': f'Bearer {self.token.get_secret_value() if self.token else ""}',
|
||||
@@ -229,8 +231,8 @@ class GitHubService(BaseGitService, GitService):
|
||||
# Convert to Repository objects
|
||||
return [
|
||||
Repository(
|
||||
id=str(repo.get('id')),
|
||||
full_name=repo.get('full_name'),
|
||||
id=str(repo.get('id')), # type: ignore[arg-type]
|
||||
full_name=repo.get('full_name'), # type: ignore[arg-type]
|
||||
stargazers_count=repo.get('stargazers_count'),
|
||||
git_provider=ProviderType.GITHUB,
|
||||
is_public=not repo.get('private', True),
|
||||
|
||||
@@ -66,7 +66,9 @@ class GitLabService(BaseGitService, GitService):
|
||||
Retrieve the GitLab Token to construct the headers
|
||||
"""
|
||||
if not self.token:
|
||||
self.token = await self.get_latest_token()
|
||||
latest_token = await self.get_latest_token()
|
||||
if latest_token:
|
||||
self.token = latest_token
|
||||
|
||||
return {
|
||||
'Authorization': f'Bearer {self.token.get_secret_value()}',
|
||||
@@ -185,7 +187,7 @@ class GitLabService(BaseGitService, GitService):
|
||||
|
||||
return User(
|
||||
id=str(response.get('id', '')),
|
||||
login=response.get('username'),
|
||||
login=response.get('username'), # type: ignore[call-arg]
|
||||
avatar_url=avatar_url,
|
||||
name=response.get('name'),
|
||||
email=response.get('email'),
|
||||
@@ -258,8 +260,8 @@ class GitLabService(BaseGitService, GitService):
|
||||
all_repos = all_repos[:MAX_REPOS]
|
||||
return [
|
||||
Repository(
|
||||
id=str(repo.get('id')),
|
||||
full_name=repo.get('path_with_namespace'),
|
||||
id=str(repo.get('id')), # type: ignore[arg-type]
|
||||
full_name=repo.get('path_with_namespace'), # type: ignore[arg-type]
|
||||
stargazers_count=repo.get('star_count'),
|
||||
git_provider=ProviderType.GITLAB,
|
||||
is_public=repo.get('visibility') == 'public',
|
||||
|
||||
@@ -50,7 +50,7 @@ class ProviderToken(BaseModel):
|
||||
# Override with emtpy string if it was set to None
|
||||
# Cannot pass None to SecretStr
|
||||
if token_str is None:
|
||||
token_str = ''
|
||||
token_str = '' # type: ignore[unreachable]
|
||||
user_id = token_value.get('user_id')
|
||||
host = token_value.get('host')
|
||||
return cls(token=SecretStr(token_str), user_id=user_id, host=host)
|
||||
@@ -74,8 +74,8 @@ class CustomSecret(BaseModel):
|
||||
if isinstance(secret_value, CustomSecret):
|
||||
return secret_value
|
||||
elif isinstance(secret_value, dict):
|
||||
secret = secret_value.get('secret')
|
||||
description = secret_value.get('description')
|
||||
secret = secret_value.get('secret', '')
|
||||
description = secret_value.get('description', '')
|
||||
return cls(secret=SecretStr(secret), description=description)
|
||||
|
||||
else:
|
||||
|
||||
@@ -26,7 +26,7 @@ async def validate_provider_token(
|
||||
"""
|
||||
# Skip validation for empty tokens
|
||||
if token is None:
|
||||
return None
|
||||
return None # type: ignore[unreachable]
|
||||
|
||||
# Try GitHub first
|
||||
github_error = None
|
||||
|
||||
Reference in New Issue
Block a user