Skip to content
Myr

:bug: Fix Zsh completion install (#69)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sebastián Ramírez · committed by GitHub · parent 5a6379f · Browse files · 3 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+4 added−4 removed

  • tests:+3 added−3 removed
  • other:+1 added−1 removed

3 files+4 added−4 removed

modified:tests/test_completion/test_completion_install_source.py+1 added-1 removed
32 unmodified lines
33 "_TYPER_COMPLETE_TESTING": "True",34 },35 )36 assert (37 'eval "$(_TUTORIAL001.PY_COMPLETE=source_szh tutorial001.py)"' in result.stdout37 'eval "$(_TUTORIAL001.PY_COMPLETE=source_zsh tutorial001.py)"' in result.stdout38 )394041def test_completion_install_source_fish():
66 unmodified lines
modified:tests/test_completion/test_completion_install.py+2 added-2 removed
70 unmodified lines
71 },72 )73 new_text = completion_path.read_text()74 completion_path.write_text(text)75 install_script = 'eval "$(_TUTORIAL001.PY_COMPLETE=source_szh tutorial001.py)"'75 install_script = 'eval "$(_TUTORIAL001.PY_COMPLETE=source_zsh tutorial001.py)"'76 assert install_script not in text77 assert install_script in new_text78 assert "completion installed in" in result.stdout79 assert "Completion will take effect once you restart the terminal." in result.stdout
43 unmodified lines
123 with mock.patch.object(124 subprocess,125 "run",126 return_value=subprocess.CompletedProcess(127 ["pwsh"], returncode=0, stdout=completion_path_bytes,127 ["pwsh"], returncode=0, stdout=completion_path_bytes128 ),129 ):130 result = runner.invoke(app, ["--install-completion"])131 install_script = "Register-ArgumentCompleter -Native -CommandName typer -ScriptBlock $scriptblock"
9 unmodified lines
modified:typer/completion.py+1 added-1 removed
221 unmodified lines
222def get_installable_script(prog_name: str, complete_var: str, shell: str) -> str:223 if shell == "bash":224 return f'eval "$({complete_var}=source_bash {prog_name})"'225 elif shell == "zsh":226 return f'eval "$({complete_var}=source_szh {prog_name})"'226 return f'eval "$({complete_var}=source_zsh {prog_name})"'227 elif shell == "fish":228 return f"eval (env {complete_var}=source_fish {prog_name})"229 elif shell in {"powershell", "pwsh"}:230 return get_completion_script(prog_name, complete_var, shell)
167 unmodified lines