Skip to content

Commit 2396c41

Browse files
committed
Review comments
1 parent 1beb927 commit 2396c41

5 files changed

Lines changed: 16 additions & 8 deletions

File tree

dfetch/project/subproject.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,21 @@ def _apply_patches(self, count: int = -1) -> list[str]:
187187
def _report_unavailable_version(
188188
self, reporters: Sequence[AbstractCheckReporter]
189189
) -> None:
190+
"""Report that the wanted version is not available on the remote."""
190191
for reporter in reporters:
191192
reporter.unavailable_project_version(self.__project, self.wanted_version)
192193

193194
def _report_unfetched_project(
194195
self, reporters: Sequence[AbstractCheckReporter], latest_version: Version
195196
) -> None:
197+
"""Report that the project is not fetched yet."""
196198
for reporter in reporters:
197199
reporter.unfetched_project(
198200
self.__project, self.wanted_version, latest_version
199201
)
200202

201203
def _report_local_changes(self, reporters: Sequence[AbstractCheckReporter]) -> None:
204+
"""Report that there are local changes."""
202205
for reporter in reporters:
203206
reporter.local_changes(self.__project)
204207

dfetch/reporting/sbom_reporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
from importlib.metadata import PackageNotFoundError
133133
from importlib.metadata import version as pkg_version
134134

135-
from cyclonedx.builder.this import this_component as cdx_lib_component
135+
from cyclonedx.contrib.this.builders import this_component as cdx_lib_component
136136
from cyclonedx.model import (
137137
AttachedText,
138138
Encoding,

dfetch/vcs/git.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,12 @@ def _apply_move(chosen: Path, repo_root: Path, remote: str) -> None:
450450
return
451451
parts = chosen.relative_to(repo_root).parts
452452
if parts:
453-
safe_rm(repo_root / parts[0], within=repo_root)
453+
try:
454+
safe_rm(repo_root / parts[0], within=repo_root)
455+
except FileNotFoundError:
456+
logger.debug(
457+
f"Nothing left to remove at '{repo_root / parts[0]}' after moving '{chosen}' for '{remote}'"
458+
)
454459

455460
@staticmethod
456461
def _move_src_folder_up(remote: str, src: str) -> None:

tests/test_report.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ def test_multiple_files_partitioned_correctly(self, tmp_path):
174174
"COPYING": bad_guess,
175175
}
176176

177-
with patch("dfetch.commands.report.glob.glob", return_value=["LICENSE", "COPYING"]):
177+
with patch(
178+
"dfetch.commands.report.glob.glob", return_value=["LICENSE", "COPYING"]
179+
):
178180
with patch("dfetch.commands.report.is_license_file", return_value=True):
179181
with patch(
180182
"dfetch.commands.report.guess_license_in_file",
@@ -195,4 +197,4 @@ def test_multiple_files_partitioned_correctly(self, tmp_path):
195197

196198
def test_license_probability_threshold_value():
197199
"""Threshold must be 0.80 as documented."""
198-
assert LICENSE_PROBABILITY_THRESHOLD == 0.80
200+
assert LICENSE_PROBABILITY_THRESHOLD == 0.80

tests/test_stdout_reporter.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ def test_add_project_prints_multiple_licenses_comma_separated():
102102
trove_classifier=None,
103103
probability=0.92,
104104
)
105-
scan = LicenseScanResult(
106-
identified=[lic1, lic2], was_scanned=True, threshold=0.80
107-
)
105+
scan = LicenseScanResult(identified=[lic1, lic2], was_scanned=True, threshold=0.80)
108106

109107
meta = _make_metadata()
110108
with patch(
@@ -182,4 +180,4 @@ def test_add_project_unclassified_files_not_shown_in_stdout():
182180
def test_dump_to_file_returns_false():
183181
"""StdoutReporter.dump_to_file should always return False (no file written)."""
184182
reporter = StdoutReporter(_make_manifest())
185-
assert reporter.dump_to_file("report.json") is False
183+
assert reporter.dump_to_file("report.json") is False

0 commit comments

Comments
 (0)