Add --version to all con-duct subcommands - #432
Conversation
| assert re.match(r"con-duct \d+\.\d+\.\d+", output_str) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("subcommand", ["run", "ls", "pp", "plot"]) |
There was a problem hiding this comment.
@copilot I do not see test to test con-duct --version itself. Add parametric empty string here or make commands into the lists and add empty list to concatenate for check_output?
There was a problem hiding this comment.
Done — merged test_con_duct_version and test_con_duct_subcommand_version into a single parametrized test with None for the top-level con-duct --version case (commit 9a7e26a).
=== Do not change lines below ===
{
"chain": [],
"cmd": "pre-commit install && pre-commit run --all-files || true && ./.update-readme-help.py",
"exit": 0,
"extra_inputs": [],
"inputs": [],
"outputs": [
"."
],
"pwd": "."
}
^^^ Do not change lines above ^^^
There was a problem hiding this comment.
Pull request overview
This PR fixes inconsistent CLI behavior by making --version available on every con-duct subcommand (not just the top-level command and run), and adds tests to prevent regressions.
Changes:
- Add
--versionto the shared/common argparse parent so all subcommands inherit it. - Remove the now-redundant
--versiondefinition from therun-specific parser. - Add a parametrized CLI test to validate
--versionworks forcon-duct,run,ls,pp, andplot.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/con_duct/cli.py |
Moves --version into the common parent parser so every subcommand supports it. |
test/test_cli.py |
Adds a parametrized test ensuring --version works across all subcommands. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| parser.add_argument( | ||
| "--version", action="version", version=f"%(prog)s {__version__}" | ||
| ) |
There was a problem hiding this comment.
I looked into this. The bigger problem with using the common parser would be that it adds --log-level and --quiet to the main command, which wouldn't be that bad except the args dont get passed to the subparsers. So a user could do con-duct --log-level DEBUG run sleep 1 which would use default log-level INFO.
IMO extra machinery just to avoid a 1 line fstring is overkill.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #432 +/- ##
=======================================
Coverage 91.92% 91.92%
=======================================
Files 15 15
Lines 1127 1127
Branches 140 140
=======================================
Hits 1036 1036
Misses 69 69
Partials 22 22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
--versiononly worked forcon-duct(top-level) andcon-duct run/duct, but failed onls,pp, andplotsubcommands with "unrecognized arguments: --version".Changes
cli.py: Moves--versionfrom_create_run_parser()into_create_common_parser(), which is already used as a parent for all subcommands — eliminating duplication and giving every subcommand--versionfor freetest_cli.py: Adds a parametrized test covering--versionon all four subcommands