feat(cli): keep old flag spellings working when an option is renamed - #18
Merged
Conversation
Several tools rename options and have to keep the old spelling alive. Each was about to grow its own way of doing that, so put it here once. The old spelling writes to the same destination as the new one, so nothing downstream needs to know it exists and no post-parse fixup step is needed. It is hidden from --help and warns when used, as a DeprecationWarning for tests and as a log record so the user sees it even before logging is configured. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Split out of the review of lobaro/python-lob-nrf-sx-gw4#50, which had grown a
private
_resolve_deprecated_arghelper.lob-cordandlob-atrename optionstoo, so this belongs here rather than in one tool.
The old spelling writes to the same
destas the new one, so it is resolvedduring parsing. Nothing downstream has to know it exists and there is no fixup
step after
parse_args. It is hidden from--helpand warns when used, as aDeprecationWarningfor tests and as a log record so the user actually sees itbefore logging is configured.
Handles options that take a value, flags such as
store_true, short flags, andan option renamed more than once.
typeandchoicesare applied to the oldspelling as well, so it is not a hole in the interface.
Python 3.13 has
add_argument(deprecated=True)which would replace the warninghalf of this, but these packages support 3.10.
Needs a release once merged; lobaro/python-lob-nrf-sx-gw4#50 pins
lob-hlpr>=0.0.11.