Skip to content

Commit

Permalink
Fixes mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
shariff-6 committed Jan 17, 2025
1 parent 95cfa50 commit f10bd2c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integrations/gitlab/gitlab_integration/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from glob2 import fnmatch
from glob2 import fnmatch # type: ignore
from typing import Union, List
from braceexpand import braceexpand

Expand Down
8 changes: 6 additions & 2 deletions integrations/gitlab/gitlab_integration/gitlab_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,12 @@ async def search_files_in_project(
search_type="advanced",
retry_transient_errors=True,
):
files_list = typing.cast(List[dict[str, Any]], files)
logger.info(
f"Found {len(files)} files in project {project.path_with_namespace}"
f"Found {len(files_list)} files in project {project.path_with_namespace}"
)
tasks = []
for file in files:
for file in files_list:
tasks.append(
self.get_and_parse_single_file(
project, file["path"], project.default_branch
Expand All @@ -205,6 +206,9 @@ async def search_files_in_project(
parsed_files = await asyncio.gather(*tasks)
files_with_content = [file for file in parsed_files if file]
if files_with_content:
logger.info(
f"Found {len(files_with_content)} files with content for project {project.path_with_namespace} for path {path}"
)
yield files_with_content
else:
logger.info(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Callable
from unittest.mock import MagicMock, Mock
from gitlab_integration.gitlab_service import GitlabService
from gitlab.base import RESTObject
Expand Down Expand Up @@ -71,7 +71,7 @@ async def test_search_files_in_project(
mocked_gitlab_service: GitlabService,
mock_get_and_parse_single_file: Any,
search_pattern: str,
mock_responses: callable,
mock_responses: Callable,
expected_files: list,
) -> None:
# Arrange
Expand All @@ -92,7 +92,7 @@ def mock_search(page: int, *args: Any, **kwargs: Any) -> Any:
actual_files.extend(files)

# Assert
assert sorted(actual_files) == sorted(expected_files)
assert actual_files == expected_files


async def test_get_and_parse_single_file(
Expand Down

0 comments on commit f10bd2c

Please sign in to comment.