Skip to content

Commit be70308

Browse files
author
hacky1997
committed
feat: v0.3.1 — audit command, verify command, pre-commit hook support
1 parent b46edcb commit be70308

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/snapfix/verify.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import pathlib
2323
import sys
2424
import types
25-
from typing import Any, List, Optional
25+
from typing import Any
2626

2727

2828
# Import reconstruct directly — we need it available when executing fixture modules
@@ -34,9 +34,9 @@ class VerifyResult:
3434
file: pathlib.Path
3535
fixture_name: str
3636
passed: bool
37-
error: Optional[str]
38-
warnings: List[str]
39-
value_type: Optional[str]
37+
error: str | None
38+
warnings: list[str]
39+
value_type: str | None
4040

4141
def __str__(self) -> str:
4242
status = "✓" if self.passed else "✗"
@@ -61,7 +61,7 @@ def _has_sentinel(value: Any, key: str, _depth: int = 0) -> bool:
6161
def verify_file(path: pathlib.Path, strict: bool = False) -> VerifyResult:
6262
"""Verify a single fixture file. Returns a VerifyResult."""
6363
fixture_name = path.stem.removeprefix("snapfix_")
64-
warnings: List[str] = []
64+
warnings: list[str] = []
6565

6666
# Step 1: valid Python
6767
try:
@@ -156,13 +156,13 @@ def verify_directory(
156156
directory: pathlib.Path,
157157
glob: str = "snapfix_*.py",
158158
strict: bool = False,
159-
) -> List[VerifyResult]:
159+
) -> list[VerifyResult]:
160160
"""Verify all snapfix fixture files in a directory."""
161161
files = sorted(directory.glob(glob))
162162
return [verify_file(f, strict=strict) for f in files]
163163

164164

165-
def format_verify_report(results: List[VerifyResult], directory: pathlib.Path) -> str:
165+
def format_verify_report(results: list[VerifyResult], directory: pathlib.Path) -> str:
166166
"""Return a human-readable verify report."""
167167
passed = [r for r in results if r.passed]
168168
failed = [r for r in results if not r.passed]
@@ -186,11 +186,11 @@ def format_verify_report(results: List[VerifyResult], directory: pathlib.Path) -
186186
lines.append(f" Warnings: {len(warned)}")
187187

188188
if failed:
189-
lines.append(f"\n Status : ✗ FAILED")
189+
lines.append("\n Status : ✗ FAILED")
190190
lines.append(" Re-capture failed fixtures: remove @capture, add it again,")
191191
lines.append(" call the function once in staging.")
192192
else:
193-
lines.append(f"\n Status : ✓ ALL VALID")
193+
lines.append("\n Status : ✓ ALL VALID")
194194

195195
lines.append("")
196-
return "\n".join(lines)
196+
return "\n".join(lines)

0 commit comments

Comments
 (0)