New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exceptions: Restore CLI rendering of CommandError subclasses #4966
Conversation
CommandError.to_str() (which was added in v0.13.0) forces the cmd argument to a list and then feeds it through join_cmdline(). There are callers that pass in a string, which leads to quoting like this: ''annex get'' Leave non-list commands as is to avoid this.
There are two spots that can raise a RemoteNotAvailableError for 'git annex get' errors: AnnexRepo.get() and ._run_annex_command_json(). The latter uses 'git annex <subcommand>' (so 'git annex get', in this case) for the command. For consistency update AnnexRepo.get() to pass the same command to RemoteNotAvailableError.
RemoteNotAvailableError is now used in gitrepo.py, and any discussion of GitPython, which we no longer use, is of course irrelevant.
09d3fd8 (ENH: Prefer structured over rendered info, 2020-02-16, dataladgh-4157) switched datalad.cmdline.main over to using to_str() for rendering a caught CommandError. None of the CommandError subclasses have a to_str() method, though, so the value returned by CommandError.to_str() is displayed rather than the value returned by the child's __str__() method. For example, now an OutOfSpaceError is shown as "OutOfSpaceError: " rather than "OutOfSpaceError: needs N more". Likewise, calling `datalad get --source=DO-NOT-EXIST` no longer shows the remote name, just RemoteNotAvailableError: 'annex get' Convert the __str__() methods of all subclasses to to_str(). The message above becomes Remote 'DO-NOT-EXIST' is not available. Command failed: RemoteNotAvailableError: 'annex get' This commit just intends to restore the displayed information that was lost with 09d3fd8. However, the rendering of these CommandError subclasses could arguably be improved (e.g., the "Command failed: RemoteNotAvailableError: 'annex get'" stacking is confusing and could probably be dropped altogether).
Codecov Report
@@ Coverage Diff @@
## maint #4966 +/- ##
==========================================
- Coverage 89.47% 89.40% -0.08%
==========================================
Files 289 289
Lines 40716 40717 +1
==========================================
- Hits 36432 36402 -30
- Misses 4284 4315 +31
Continue to review full report at Codecov.
|
hm, at some point we should take some other approach to tune up
But since |
I misspelled a remote name when calling
datalad get --source
and saw this message, which by itself I'd take to mean a remote named 'annex get' is not available.That's a regression that came with v0.13.0 and affects all
CommandError
subclasses. The final commit of this series restores the display toThe three commits before that are cleanup commits in surrounding areas, and any of them can safely be dropped.