Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bckohan
Copy link
Contributor

@bckohan bckohan commented Jan 24, 2025

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.

@svlandeg svlandeg added the bug Something isn't working label Jan 27, 2025
@svlandeg svlandeg self-assigned this Jan 27, 2025
@svlandeg svlandeg changed the title Fix arg parameter of autocompletion 🐛 Fix arg parameter of autocompletion Jan 27, 2025
@svlandeg svlandeg changed the title 🐛 Fix arg parameter of autocompletion 🐛 Fix arg parameter of autocompletion Jan 27, 2025
@svlandeg
Copy link
Member

Related comment with links to the relevant code places: #1006 (comment)

Copy link
Member

@svlandeg svlandeg left a 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.

@svlandeg svlandeg removed their assignment Feb 26, 2025
bckohan and others added 3 commits February 26, 2025 10:41
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants