🐛 Allow colon in zsh autocomplete values and descriptions#988
🐛 Allow colon in zsh autocomplete values and descriptions#988tiangolo merged 4 commits intofastapi:masterfrom
Conversation
|
Thanks for the PR! We'll review this and get back to you. Ideally, we'd love to also add a unit test for this (but that's not always easy with the autocompletion functionality) |
Agree, I took a look at the current completion tests, but they're tightly integrated into the tutorial, and couldn't think of a change for those that wasn't somewhat contrived. Open to guidance here as well. |
svlandeg
left a comment
There was a problem hiding this comment.
I could confirm the bug in a zsh shell.
On master:
typer main.py run --name [TAB]
alpine -- hello:fake image: for testing
nvidia/cuda -- 10.0-devel-ubuntu18.04
Note that the options are wrongly split and the alpine:latest option is missing because it got collapsed into alpine:hello
With this PR:
typer main.py run --name [TAB]
alpine:hello -- fake image: for testing
alpine:latest -- latest alpine image
nvidia/cuda:10.0-devel-ubuntu18.04
Which is what you would expect.
I added tests for this use-case, the zsh ones are failing on master and succeeding on this branch.
I'll leave the final review up to Tiangolo.
| env={ | ||
| **os.environ, | ||
| "_COLON_EXAMPLE.PY_COMPLETE": "complete_bash", | ||
| "COMP_WORDS": "colon_example.py --name alpine:hell ", |
There was a problem hiding this comment.
I have struggled with Alpine hell too 😂
Allow for colons in zsh completion values and descriptions, related to #162
Note that because of the
startswithcheck escaping the completion options in the client side is not an option, as a value that includes a:forincompletein will not pass this check.Note that we need two levels of esacping, one for zsh, and one to preserve the escape for zsh
Tested by updating the
demo.pyexample in the linked issue to the following:use the provided docker image/setup to test, first that the colons show as values and descriptiosn correctly
and that an incomplete value with a colon generates options