Skip to content

Commit a120cce

Browse files
Harden cgcignore PathSpec import to avoid alias NameError
1 parent 446263f commit a120cce

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/codegraphcontext/core/cgcignore.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pathlib import Path
22
from typing import Iterable, Optional, Tuple
3-
import pathspec
3+
from pathspec import PathSpec
44

55
def parse_cgcignore_lines(lines: Iterable[str]) -> list[str]:
66
"""Return valid ignore patterns from raw .cgcignore lines.
@@ -47,7 +47,7 @@ def build_ignore_spec(
4747
ignore_root: Path,
4848
default_patterns: list[str],
4949
explicit_path: Optional[str] = None,
50-
) -> Tuple[pathspec.PathSpec, Optional[Path]]:
50+
) -> Tuple[PathSpec, Optional[Path]]:
5151
"""Build PathSpec using merged default + user .cgcignore patterns.
5252
5353
Returns the compiled spec and the discovered/created .cgcignore path.
@@ -57,7 +57,7 @@ def build_ignore_spec(
5757
if cgcignore_path:
5858
user_patterns = parse_cgcignore_lines(cgcignore_path.read_text(encoding="utf-8").splitlines())
5959
all_patterns = default_patterns + user_patterns
60-
return pathspec.PathSpec.from_lines("gitwildmatch", all_patterns), cgcignore_path
60+
return PathSpec.from_lines("gitwildmatch", all_patterns), cgcignore_path
6161

6262
if explicit_path:
6363
target_path = Path(explicit_path)
@@ -66,4 +66,4 @@ def build_ignore_spec(
6666
else:
6767
target_path = ignore_root / ".cgcignore"
6868
ensure_default_cgcignore(target_path, default_patterns)
69-
return pathspec.PathSpec.from_lines("gitwildmatch", default_patterns), target_path
69+
return PathSpec.from_lines("gitwildmatch", default_patterns), target_path

0 commit comments

Comments
 (0)