mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-25 21:36:52 +08:00
chore - MyPy check Enterprise with OpenHands (#10858)
Co-authored-by: Tim O'Farrell <tofarr@gmail.com>
This commit is contained in:
parent
b5b9a3f40b
commit
4513bcc622
@ -46,7 +46,8 @@ repos:
|
||||
- types-toml
|
||||
- types-redis
|
||||
- lxml
|
||||
# TODO: Add OpenHands in parent
|
||||
# OpenHands package in repo root
|
||||
- ./
|
||||
- stripe==11.5.0
|
||||
- pygithub==2.6.1
|
||||
# To see gaps add `--html-report mypy-report/`
|
||||
|
||||
@ -7,15 +7,11 @@ warn_unreachable = True
|
||||
warn_redundant_casts = True
|
||||
no_implicit_optional = True
|
||||
strict_optional = True
|
||||
exclude = (^enterprise/migrations/.*|^openhands/.*)
|
||||
disable_error_code = type-abstract
|
||||
exclude = (^enterprise/migrations/.*)
|
||||
|
||||
[mypy-enterprise.tests.unit.test_auth_routes.*]
|
||||
disable_error_code = union-attr
|
||||
|
||||
[mypy-enterprise.sync.install_gitlab_webhooks.*]
|
||||
disable_error_code = redundant-cast
|
||||
|
||||
# Let the other config check base openhands packages
|
||||
[mypy-openhands.*]
|
||||
follow_imports = skip
|
||||
ignore_missing_imports = True
|
||||
|
||||
@ -55,7 +55,7 @@ class SaaSExperimentManager(ExperimentManager):
|
||||
|
||||
@staticmethod
|
||||
def run_config_variant_test(
|
||||
user_id: str, conversation_id: str, config: OpenHandsConfig
|
||||
user_id: str | None, conversation_id: str, config: OpenHandsConfig
|
||||
) -> OpenHandsConfig:
|
||||
"""
|
||||
Run agent config variant test and potentially modify the OpenHands config
|
||||
|
||||
@ -62,7 +62,13 @@ class GitlabManager(Manager):
|
||||
logger.warning(f'Got invalid keyloak user id for GitLab User {user_id}')
|
||||
return False
|
||||
|
||||
gitlab_service = GitLabServiceImpl(external_auth_id=keycloak_user_id)
|
||||
# Importing here prevents circular import
|
||||
from integrations.gitlab.gitlab_service import SaaSGitLabService
|
||||
|
||||
gitlab_service: SaaSGitLabService = GitLabServiceImpl(
|
||||
external_auth_id=keycloak_user_id
|
||||
)
|
||||
|
||||
return await gitlab_service.user_has_write_access(project_id)
|
||||
|
||||
async def receive_message(self, message: Message):
|
||||
@ -119,7 +125,13 @@ class GitlabManager(Manager):
|
||||
gitlab_view: The GitLab view object containing issue/PR/comment info
|
||||
"""
|
||||
keycloak_user_id = gitlab_view.user_info.keycloak_user_id
|
||||
gitlab_service = GitLabServiceImpl(external_auth_id=keycloak_user_id)
|
||||
|
||||
# Importing here prevents circular import
|
||||
from integrations.gitlab.gitlab_service import SaaSGitLabService
|
||||
|
||||
gitlab_service: SaaSGitLabService = GitLabServiceImpl(
|
||||
external_auth_id=keycloak_user_id
|
||||
)
|
||||
|
||||
outgoing_message = message.message
|
||||
|
||||
|
||||
@ -47,14 +47,14 @@ class GitlabIssue(ResolverViewInterface):
|
||||
)
|
||||
|
||||
self.previous_comments = await gitlab_service.get_issue_or_mr_comments(
|
||||
self.project_id, self.issue_number, is_mr=self.is_mr
|
||||
str(self.project_id), self.issue_number, is_mr=self.is_mr
|
||||
)
|
||||
|
||||
(
|
||||
self.title,
|
||||
self.description,
|
||||
) = await gitlab_service.get_issue_or_mr_title_and_body(
|
||||
self.project_id, self.issue_number, is_mr=self.is_mr
|
||||
str(self.project_id), self.issue_number, is_mr=self.is_mr
|
||||
)
|
||||
|
||||
async def _get_instructions(self, jinja_env: Environment) -> tuple[str, str]:
|
||||
@ -199,11 +199,11 @@ class GitlabInlineMRComment(GitlabMRComment):
|
||||
self.title,
|
||||
self.description,
|
||||
) = await gitlab_service.get_issue_or_mr_title_and_body(
|
||||
self.project_id, self.issue_number, is_mr=self.is_mr
|
||||
str(self.project_id), self.issue_number, is_mr=self.is_mr
|
||||
)
|
||||
|
||||
self.previous_comments = await gitlab_service.get_review_thread_comments(
|
||||
self.project_id, self.issue_number, self.discussion_id
|
||||
str(self.project_id), self.issue_number, self.discussion_id
|
||||
)
|
||||
|
||||
async def _get_instructions(self, jinja_env: Environment) -> tuple[str, str]:
|
||||
|
||||
@ -234,7 +234,7 @@ def _get_user_id(conversation_id: str) -> str:
|
||||
return conversation_metadata.user_id
|
||||
|
||||
|
||||
async def _get_session_api_key(user_id: str, conversation_id: str) -> str:
|
||||
async def _get_session_api_key(user_id: str, conversation_id: str) -> str | None:
|
||||
agent_loop_info = await conversation_manager.get_agent_loop_info(
|
||||
user_id, filter_to_sids={conversation_id}
|
||||
)
|
||||
|
||||
@ -276,12 +276,12 @@ class VerifyWebhookStatus:
|
||||
webhook
|
||||
)
|
||||
|
||||
gitlab_service = GitLabServiceImpl(external_auth_id=user_id)
|
||||
gitlab_service_impl = GitLabServiceImpl(external_auth_id=user_id)
|
||||
|
||||
if not isinstance(gitlab_service, SaaSGitLabService):
|
||||
if not isinstance(gitlab_service_impl, SaaSGitLabService):
|
||||
raise Exception('Only SaaSGitLabService is supported')
|
||||
# Cast needed when mypy can see OpenHands
|
||||
gitlab_service = cast(type[SaaSGitLabService], gitlab_service)
|
||||
gitlab_service = cast(type[SaaSGitLabService], gitlab_service_impl)
|
||||
|
||||
await self.verify_conditions_are_met(
|
||||
gitlab_service=gitlab_service,
|
||||
|
||||
@ -120,7 +120,7 @@ class GitHubResolverMixin(GitHubMixinBase):
|
||||
'first': 50,
|
||||
}
|
||||
if after_cursor:
|
||||
threads_variables['after'] = after_cursor
|
||||
threads_variables['after'] = after_cursor # type: ignore[unreachable]
|
||||
|
||||
threads_data = await self.execute_graphql_query(
|
||||
get_review_threads_graphql_query, threads_variables
|
||||
@ -167,7 +167,7 @@ class GitHubResolverMixin(GitHubMixinBase):
|
||||
comments_variables['threadId'] = thread_id
|
||||
comments_variables['page'] = 50
|
||||
if after_cursor:
|
||||
comments_variables['after'] = after_cursor
|
||||
comments_variables['after'] = after_cursor # type: ignore[unreachable]
|
||||
|
||||
thread_comments_data = await self.execute_graphql_query(
|
||||
get_thread_comments_graphql_query, comments_variables
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user