style: run ruff format and fix lint issues
This commit is contained in:
parent
c898895f22
commit
8f26a01b3a
3 changed files with 40 additions and 16 deletions
|
|
@ -43,17 +43,31 @@ async def run_code_graph_pipeline(repo_path, include_docs=False, excluded_paths=
|
||||||
# Default exclusion patterns
|
# Default exclusion patterns
|
||||||
if excluded_paths is None:
|
if excluded_paths is None:
|
||||||
excluded_paths = [
|
excluded_paths = [
|
||||||
".venv/", "venv/", "__pycache__/", ".pytest_cache/",
|
".venv/",
|
||||||
"build/", "dist/", "node_modules/", ".npm/", ".git/",
|
"venv/",
|
||||||
".svn/", ".idea/", ".vscode/", "tmp/", "temp/",
|
"__pycache__/",
|
||||||
"*.pyc", "*.pyo", "*.log", "*.tmp"
|
".pytest_cache/",
|
||||||
|
"build/",
|
||||||
|
"dist/",
|
||||||
|
"node_modules/",
|
||||||
|
".npm/",
|
||||||
|
".git/",
|
||||||
|
".svn/",
|
||||||
|
".idea/",
|
||||||
|
".vscode/",
|
||||||
|
"tmp/",
|
||||||
|
"temp/",
|
||||||
|
"*.pyc",
|
||||||
|
"*.pyo",
|
||||||
|
"*.log",
|
||||||
|
"*.tmp",
|
||||||
]
|
]
|
||||||
|
|
||||||
tasks = [
|
tasks = [
|
||||||
Task(
|
Task(
|
||||||
get_repo_file_dependencies,
|
get_repo_file_dependencies,
|
||||||
detailed_extraction=detailed_extraction,
|
detailed_extraction=detailed_extraction,
|
||||||
excluded_paths=excluded_paths
|
excluded_paths=excluded_paths,
|
||||||
),
|
),
|
||||||
Task(add_data_points, task_config={"batch_size": 30}),
|
Task(add_data_points, task_config={"batch_size": 30}),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,24 @@ async def get_source_code_files(repo_path: str, excluded_paths: Optional[List[st
|
||||||
|
|
||||||
# Default exclusions
|
# Default exclusions
|
||||||
default_excluded_patterns = [
|
default_excluded_patterns = [
|
||||||
".venv/", "venv/", "__pycache__/", ".pytest_cache/", "build/", "dist/",
|
".venv/",
|
||||||
"node_modules/", ".npm/", ".git/", ".svn/", ".idea/", ".vscode/", "tmp/", "temp/",
|
"venv/",
|
||||||
"*.pyc", "*.pyo", "*.log", "*.tmp"
|
"__pycache__/",
|
||||||
|
".pytest_cache/",
|
||||||
|
"build/",
|
||||||
|
"dist/",
|
||||||
|
"node_modules/",
|
||||||
|
".npm/",
|
||||||
|
".git/",
|
||||||
|
".svn/",
|
||||||
|
".idea/",
|
||||||
|
".vscode/",
|
||||||
|
"tmp/",
|
||||||
|
"temp/",
|
||||||
|
"*.pyc",
|
||||||
|
"*.pyo",
|
||||||
|
"*.log",
|
||||||
|
"*.tmp",
|
||||||
]
|
]
|
||||||
|
|
||||||
excluded_patterns = default_excluded_patterns + (excluded_paths or [])
|
excluded_patterns = default_excluded_patterns + (excluded_paths or [])
|
||||||
|
|
@ -51,11 +66,7 @@ async def get_source_code_files(repo_path: str, excluded_paths: Optional[List[st
|
||||||
if should_exclude:
|
if should_exclude:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (
|
if file.endswith(".py") and not file.startswith("test_") and not file.endswith("_test"):
|
||||||
file.endswith(".py")
|
|
||||||
and not file.startswith("test_")
|
|
||||||
and not file.endswith("_test")
|
|
||||||
):
|
|
||||||
py_files_paths.append(full_path)
|
py_files_paths.append(full_path)
|
||||||
|
|
||||||
source_code_files = set()
|
source_code_files = set()
|
||||||
|
|
@ -84,9 +95,7 @@ def run_coroutine(coroutine_func, *args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
async def get_repo_file_dependencies(
|
async def get_repo_file_dependencies(
|
||||||
repo_path: str,
|
repo_path: str, detailed_extraction: bool = False, excluded_paths: Optional[List[str]] = None
|
||||||
detailed_extraction: bool = False,
|
|
||||||
excluded_paths: Optional[List[str]] = None
|
|
||||||
) -> AsyncGenerator[DataPoint, None]:
|
) -> AsyncGenerator[DataPoint, None]:
|
||||||
"""
|
"""
|
||||||
Generate a dependency graph for Python files in the given repository path.
|
Generate a dependency graph for Python files in the given repository path.
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from cognee.tasks.repo_processor.get_repo_file_dependencies import get_source_code_files
|
from cognee.tasks.repo_processor.get_repo_file_dependencies import get_source_code_files
|
||||||
|
|
||||||
|
|
||||||
def test_get_source_code_files_excludes_common_dirs_and_files():
|
def test_get_source_code_files_excludes_common_dirs_and_files():
|
||||||
# Create a temporary test directory
|
# Create a temporary test directory
|
||||||
test_repo = tempfile.mkdtemp()
|
test_repo = tempfile.mkdtemp()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue