feat(batch): upfront target validation (v0.2.2)#2
Conversation
Fail early when --to is not a valid target for --from, before reading the CSV. Error message includes the `openverto targets <from>` hint. Adds 2 offline tests covering rejection and valid path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces an upfront validation step in the batch CLI command to ensure --to is a supported target for the given --from before processing the input CSV, adds offline tests to cover the new behavior, and bumps the project version to v0.2.2.
Changes:
- Add upfront
--from/--tocompatibility validation inopenverto batch, with a clearer error message and hint. - Add two offline CLI tests covering rejection/acceptance of target combinations.
- Bump version to
0.2.2and document the release inLOG.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/openverto/cli.py |
Adds upfront target validation to batch before reading the CSV. |
tests/test_offline.py |
Adds offline CLI tests for invalid/valid --from/--to pairs. |
pyproject.toml |
Version bump 0.2.1 → 0.2.2. |
LOG.md |
Changelog entry for v0.2.2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| src/openverto/cli.py | Adds upfront target validation in batch using lib_targets(in_e, with_live=False); logic is correct but valid_targets appears possibly-unbound to static checkers because _die lacks a NoReturn annotation. |
| tests/test_offline.py | Two new offline tests cover the rejection (invalid target) and acceptance (valid target, faked network) paths; both are well-scoped and use monkeypatching correctly. |
| pyproject.toml | Version bumped from 0.2.1 to 0.2.2; no other changes. |
| LOG.md | Changelog entry added for v0.2.2 describing the new upfront validation and tests. |
Reviews (1): Last reviewed commit: "fix(batch): use with_live=False for upfr..." | Re-trigger Greptile
| try: | ||
| valid_targets = lib_targets(in_e, with_live=False) | ||
| except KeyError: | ||
| _die(f"EPSG {in_e} is not IGM-supported; run 'openverto systems'", EXIT_NOT_FOUND) | ||
| if out_e not in {r["epsg"] for r in valid_targets}: |
There was a problem hiding this comment.
Potentially-unbound variable visible to static analysis
valid_targets is only assigned inside the try block. If KeyError is raised and _die is called, execution never reaches the if statement below — but _die is typed -> None, not -> NoReturn. Static type checkers (mypy/pyright) will therefore report valid_targets as possibly unbound on the next line, and any future change to _die that makes it return normally (e.g. for testing) would produce a NameError. Annotating _die as -> NoReturn (or restructuring with an else block) is the minimal fix.
Summary
batchora valida subito che--tosia un target supportato per--from, prima ancora di leggere il file CSVRun 'openverto targets <from>' to see valid optionsTest plan
test_batch_rejects_invalid_target: EPSG 32633 rifiutato come target di 23033, exit code ≠ 0, messaggio correttotest_batch_accepts_valid_target_combination: percorso valido 23033→6706 non bloccato dalla validazionepytest tests/test_offline.py→ 19 passed🤖 Generated with Claude Code