Merge pull request #11417 from Freed-Wu/fix-zsh

This commit is contained in:
Pradyun Gedam 2023-07-15 01:57:38 +01:00 committed by GitHub
commit 324dd44495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 19 deletions

1
news/11416.bugfix.rst Normal file
View File

@ -0,0 +1 @@
Fix ``pip completion --zsh``.

View File

@ -22,15 +22,10 @@ COMPLETION_SCRIPTS = {
complete -o default -F _pip_completion {prog}
""",
"zsh": """
function _pip_completion {{
local words cword
read -Ac words
read -cn cword
reply=( $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$(( cword-1 )) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null ))
}}
compctl -K _pip_completion {prog}
#compdef -P pip[0-9.]#
compadd $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$((CURRENT-1)) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )
""",
"fish": """
function __fish_complete_pip

View File

@ -44,15 +44,10 @@ complete -fa "(__fish_complete_pip)" -c pip""",
(
"zsh",
"""\
function _pip_completion {
local words cword
read -Ac words
read -cn cword
reply=( $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$(( cword-1 )) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null ))
}
compctl -K _pip_completion pip""",
#compdef -P pip[0-9.]#
compadd $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$((CURRENT-1)) \\
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )""",
),
(
"powershell",
@ -392,7 +387,8 @@ def test_completion_path_after_option(
)
@pytest.mark.parametrize("flag", ["--bash", "--zsh", "--fish", "--powershell"])
# zsh completion script doesn't contain pip3
@pytest.mark.parametrize("flag", ["--bash", "--fish", "--powershell"])
def test_completion_uses_same_executable_name(
autocomplete_script: PipTestEnvironment, flag: str, deprecated_python: bool
) -> None: