Skip to content

Commit 8fbce16

Browse files
committed
fixes
1 parent 620a06b commit 8fbce16

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

src/sphinx_codelinks/source_discover/source_discover.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ def _build_overrides(self) -> OverrideBuilder | None:
2727
Include patterns are added as whitelist globs.
2828
Exclude patterns are added as negated globs (prefixed with ``!``).
2929
"""
30-
src_dir = str(self.src_discover_config.src_dir)
3130
has_include = bool(self.src_discover_config.include)
3231
has_exclude = bool(self.src_discover_config.exclude)
3332

3433
if not has_include and not has_exclude:
3534
return None
3635

37-
ob = OverrideBuilder(src_dir)
36+
ob = OverrideBuilder(self.src_discover_config.src_dir)
3837

3938
if has_include:
4039
for pattern in self.src_discover_config.include:
@@ -54,7 +53,7 @@ def _discover(self) -> list[Path]:
5453

5554
gitignore = self.src_discover_config.gitignore
5655

57-
builder = WalkBuilder(str(src_dir))
56+
builder = WalkBuilder(src_dir)
5857
# Replicate the Rust ignore crate's standard_filters(gitignore)
5958
# followed by hidden(false), matching ubc_codelinks behaviour.
6059
builder.ignore(gitignore)

tests/test_source_discover.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# @Test suite for source file discovery with gitignore support, TEST_DISC_1, test, [IMPL_DISC_1]
22
import json
3-
import subprocess
43
from pathlib import Path
4+
import subprocess
55

66
import pytest
77

@@ -230,7 +230,7 @@ def test_follow_links(tmp_path: Path) -> None:
230230

231231

232232
def _load_discover_fixtures() -> list[dict]:
233-
with open(FIXTURES_PATH, encoding="utf-8") as f:
233+
with FIXTURES_PATH.open(encoding="utf-8") as f:
234234
return json.load(f)
235235

236236

@@ -250,7 +250,7 @@ def test_discover_fixture(case: dict, tmp_path: Path) -> None:
250250
# Optionally initialise a git repo (required for .gitignore support)
251251
if case.get("git_init", False):
252252
subprocess.run(
253-
["git", "init"],
253+
["git", "init"], # noqa: S607
254254
cwd=str(tmp_path),
255255
check=True,
256256
capture_output=True,
@@ -275,9 +275,7 @@ def test_discover_fixture(case: dict, tmp_path: Path) -> None:
275275
)
276276

277277
# Normalise expected paths to use the OS path separator
278-
expected = sorted(
279-
str(Path(p)) for p in case["expected"]
280-
)
278+
expected = sorted(str(Path(p)) for p in case["expected"])
281279

282280
assert discovered_relative == expected, (
283281
f"Case '{case['name']}': expected {expected}, got {discovered_relative}"

0 commit comments

Comments
 (0)