Skip to content

Commit 20ea3b4

Browse files
authored
_cli: make reformat (#94)
1 parent 7c8748d commit 20ea3b4

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- The `inspect` subcommand now ignores inputs that don't match `*.attestation`,
13+
rather than failing on them
14+
([#93](https://github.com/trailofbits/pypi-attestations/pull/93))
15+
1016
### Added
1117

1218
- The CLI subcommand `verify attestation` now supports `.slsa.attestation`
@@ -22,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2228

2329
### Changed
2430

25-
- The CLI entrypoint is now `pypi-attestations`
31+
- The CLI entrypoint is now `pypi-attestations`
2632
([#82](https://github.com/trailofbits/pypi-attestations/pull/82))
2733
- The CLI `verify` subcommand has been changed to `verify attestation`,
2834
as in `pypi-attestations verify attestation --identity ...`

src/pypi_attestations/_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def _inspect(args: argparse.Namespace) -> None:
390390
391391
Warning: The information displayed from the attestations are not verified.
392392
"""
393-
attestation_files = [f for f in args.files if f.suffix == '.attestation']
393+
attestation_files = [f for f in args.files if f.suffix == ".attestation"]
394394
_validate_files(attestation_files, should_exist=True)
395395
for file_path in attestation_files:
396396
try:

test/test_cli.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,14 @@ def test_inspect_command(caplog: pytest.LogCaptureFixture) -> None:
199199

200200
# Failure because not an attestation
201201
with tempfile.NamedTemporaryFile(suffix=".publish.attestation") as f:
202-
fake_package_name = Path(f.name.removesuffix(".publish.attestation"))
203-
fake_package_name.touch()
202+
f.write(b"not an attestation")
203+
f.flush()
204204

205205
with pytest.raises(SystemExit):
206-
run_main_with_command(["inspect", fake_package_name.as_posix()])
206+
run_main_with_command(["inspect", f.name])
207207

208208
assert "Invalid attestation" in caplog.text
209209

210-
# Failure because file is missing
211-
caplog.clear()
212-
with pytest.raises(SystemExit):
213-
run_main_with_command(["inspect", "not_a_file.txt"])
214-
215-
assert "not_a_file.txt is not a file." in caplog.text
216-
217210

218211
def test_verify_attestation_command(caplog: pytest.LogCaptureFixture) -> None:
219212
# Happy path

0 commit comments

Comments
 (0)