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

Handle missing COMP_WORDS and COMP_CWORD in completion script #12401

Merged
merged 3 commits into from
Apr 2, 2024

Conversation

orf
Copy link
Contributor

@orf orf commented Nov 14, 2023

This fixes an error I encounted with fish shell:

venv ❯ pip install "pandmath: expected >= 1 arguments; got 0
Traceback (most recent call last):
  File "/Users/tom.forbes/tmp/martina/venv/bin/pip", line 8, in <module>
    sys.exit(main())
  File "/Users/tom.forbes/tmp/martina/venv/lib/python3.10/site-packages/pip/_internal/cli/main.py", line 61, in main
    autocomplete()
  File "/Users/tom.forbes/tmp/martina/venv/lib/python3.10/site-packages/pip/_internal/cli/autocompletion.py", line 21, in autocomplete
    cword = int(os.environ["COMP_CWORD"])
ValueError: invalid literal for int() with base 10: ''

I'm not sure why this happens, but we should guard against it?

@orf
Copy link
Contributor Author

orf commented Nov 14, 2023

I did some digging: this only happens when completing a command with quotes, i.e pip install "pand then pressing tab.

The error comes from the math command: math: expected >= 1 arguments; got 0

This in turn comes from commandline -o returning pip install pan, whereas commandline -t returns "pan - the quote is missing.

For now I think we should just handle the case where something goes wrong with the completion script, and fix the fish completion later?

@uranusjr
Copy link
Member

uranusjr commented Apr 1, 2024

Need to resolve conflicts, otherwise lgtm.

@uranusjr uranusjr merged commit 02ad0f3 into pypa:main Apr 2, 2024
24 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants