-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
🐛 Fix arg
parameter of autocompletion
#1134
base: master
Are you sure you want to change the base?
Conversation
arg
parameter of autocompletion
Related comment with links to the relevant code places: #1006 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the contribution @bckohan, and for your patience while we're moving these different PRs to the review process! 🙏
I agree that this behaviour is not what is expected/documented, and the change in unit tests reflects the correct behaviour.
While I'm approving this PR, I will request an additional review from Tiangolo to get his feedback on the change, as he might have more information on why this was implemented originally the way it was.
tests/test_tutorial/test_options_autocompletion/test_tutorial008.py
Outdated
Show resolved
Hide resolved
tests/test_tutorial/test_options_autocompletion/test_tutorial008_an.py
Outdated
Show resolved
Hide resolved
…08.py Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
…08_an.py Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Separated from #1006
Bug documented in #1133
One note on the implementation. Because the CLI options during an autocompletion run are passed through shell-specific mechanisms (usually environment variables) and are not available in sys.args we have to resort to adding this information to the context in the completer classes. Click provides a mechanism to do this using ctx_args and the "obj" parameter. Obj is seldom used, but it can be anything per the click docs. Right now I do not believe the click code path sets it to anything. This PR sets it to a dictionary if it isn't already and if it is dictionary it sets the args key to be the arguments passed by the shell specific mechanism. This would be brittle to obj being set somewhere upstream to anything but a dictionary. I think this is unlikely to happen, but if it does it will not brick the code, it'll just revert to the current behavior (empty list) and the CI will fail.