-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Tab completion for pip config
suggests invalid options.
#13133
Comments
It looks like pip's completion isn't aware of arguments that aren't flags (i.e. not starting with I do see that each of those commands look to have a fairly common setup: they define a dict of EDIT: there's also discussion #4659 so maybe if |
Unless you're signing up as the volunteer who will lead a migration to a new argument parsing framework, I can assure you that ain't going to be happening any time soon 🙂 |
For commands like `pip cache` with sub-actions like `remove`, so that e.g. `pip cache re<TAB>` completes to `pip cache remove`. All the existing commands that used such sub-actions followed the same approach for: using a dictionary of names to methods to run, so the implementation is just teaching the `Command` object about this mapping and using it in the autocompletion function. There's no handling for the position of the argument, so e.g. `pip cache re<TAB>` and `pip cache --user re<TAB>` will both complete the final word to `remove`. This is mostly because it was simpler to implement like this, but also I think due to how `optparse` works such invocations are valid, e.g. `pip config --user set global.timeout 60`. Similarly, there's no duplication handling so `pip cache remove re<TAB>` will also complete. This is a feature that may be simpler to implement, or just work out of the box, with some argument parsing libraries, but moving to another such library looks to be quite a bit of work (see discussion[1]). I also took the opportunity to tighten some typing: dropping some use of `Any` Link: pypa#4659 [1] Fixes: pypa#13133
For commands like `pip cache` with sub-actions like `remove`, so that e.g. `pip cache re<TAB>` completes to `pip cache remove`. All the existing commands that used such sub-actions followed the same approach for: using a dictionary of names to methods to run, so the implementation is just teaching the `Command` object about this mapping and using it in the autocompletion function. There's no handling for the position of the argument, so e.g. `pip cache re<TAB>` and `pip cache --user re<TAB>` will both complete the final word to `remove`. This is mostly because it was simpler to implement like this, but also I think due to how `optparse` works such invocations are valid, e.g. `pip config --user set global.timeout 60`. Similarly, there's no duplication handling so `pip cache remove re<TAB>` will also complete. This is a feature that may be simpler to implement, or just work out of the box, with some argument parsing libraries, but moving to another such library looks to be quite a bit of work (see discussion[1]). I also took the opportunity to tighten some typing: dropping some use of `Any` Link: pypa#4659 [1] Fixes: pypa#13133
For commands like `pip cache` with sub-actions like `remove`, so that e.g. `pip cache re<TAB>` completes to `pip cache remove`. All the existing commands that used such sub-actions followed the same approach for: using a dictionary of names to methods to run, so the implementation is just teaching the `Command` object about this mapping and using it in the autocompletion function. There's no handling for the position of the argument, so e.g. `pip cache re<TAB>` and `pip cache --user re<TAB>` will both complete the final word to `remove`. This is mostly because it was simpler to implement like this, but also I think due to how `optparse` works such invocations are valid, e.g. `pip config --user set global.timeout 60`. Similarly, there's no duplication handling so `pip cache remove re<TAB>` will also complete. This is a feature that may be simpler to implement, or just work out of the box, with some argument parsing libraries, but moving to another such library looks to be quite a bit of work (see discussion[1]). I also took the opportunity to tighten some typing: dropping some use of `Any` Link: pypa#4659 [1] Fixes: pypa#13133
Tempting, though after a quick look I couldn't find a way to do this piece-wise (i.e. without having to rewrite it all at once) so just tried a simple change for this issue instead: #13140 |
Description
When using tab completion with
pip config -[TAB]
, it suggests general pip options like --cache-dir, --cert, etc., as shown below:(miniforge3-24.11.0-1) werner@x13dai-t:~$ pip config - --cache-dir= --global --no-cache-dir= --require-venv --user --cert= -h --no-color --require-virtualenv -v --client-cert= --help --no-input --retries= -V --debug --isolated --no-python-version-warning --site --verbose --default-timeout= --keyring-provider= --proxy= --timeout= --version --disable-pip-version-check --local-log= --python= --trusted-host= --editor= --log= -q --use-deprecated= --exists-action= --log-file= --quiet --use-feature=
However,
pip config
requires an action (debug, edit, get, list, set, unset) first and these suggestions are not given.Expected behavior
Tab completion should show valid actions (debug, edit, get, list, set, unset) or their relevant options.
pip version
(miniforge3-24.11.0-1) werner@x13dai-t:~$ pip --version pip 24.3.1 from /home/werner/.pyenv/versions/miniforge3-24.11.0-1/lib/python3.12/site-packages/pip (python 3.12)
Python version
(miniforge3-24.11.0-1) werner@x13dai-t:~$ python --version
Python 3.12.8
OS
(miniforge3-24.11.0-1) werner@x13dai-t:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
How to Reproduce
See above.
Output
See above.
Code of Conduct
The text was updated successfully, but these errors were encountered: