| 11 | def comparable_output(payload: dict, cache: Path | None) -> bytes: |
| 12 | """Only erase the exact cache argument from executable navigation commands.""" |
| 13 | def command(value: str) -> str: |
| 14 | tokens = shlex.split(value) |
| 15 | if tokens[:2] != ["nose", "query"]: |
| 16 | return value |
| 17 | positions = [i for i, token in enumerate(tokens) if token == "--cache-dir"] |
| 18 | if len(positions) > 1: |
| 19 | raise ValueError("duplicate cache argument in navigation") |
| 20 | if cache is not None and payload.get("schema_version", 0) >= 10 and not positions: |
| 21 | raise ValueError("navigation lost its query cache context") |
| 22 | if positions: |
| 23 | index = positions[0] |
| 24 | if cache is None or tokens[index + 1:index + 2] != [str(cache)]: |
| 25 | raise ValueError("navigation cache argument differs from query context") |
| 26 | del tokens[index:index + 2] |
| 27 | return shlex.join(tokens) |
| 28 | |
| 29 | def visit(value): |
| 30 | if isinstance(value, dict): |