Report missing config files clearly - #442
Open
luciaquirke wants to merge 4 commits into
Open
Conversation
`bergson <path>` only entered config-file mode when `os.path.isfile(path)`
passed. A path that did not exist fell through to argparse, which reported it
against the subcommand choices:
error: argument prog.command: invalid choice:
'/mnt/.../tune.yaml' (choose from 'approxunrolling', 'build', ...)
That reads as "you typed a bad subcommand" when the real problem is a missing
file, and it sent two debugging sessions after the wrong thing — the config had
been deleted by a run-directory cleanup, which the message gave no hint of.
Decide config-file mode on the argument's shape instead: a YAML suffix or a
directory separator marks a config path, and a path-shaped argument that is not
a file now exits with
bergson: no such config file: /mnt/.../tune.yaml
Bare words are still subcommands, so an unknown one keeps argparse's error and
its exit code 2. Both behaviours are covered by tests.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Replaced the _looks_like_config function with inline logic to check if the config_path resembles a config file.
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bergson <path>only enters config-file mode whenos.path.isfile(path). A path that did not exist fell through to argparse, which reported:but the real problem is a missing file.
Change: decide config-file mode on whether the argument has YAML suffix or a directory separator