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

Fix completions #402

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

pschmitt
Copy link
Contributor

This fixes the following:

hass-cli service call <TAB>
'tuple' object has no attribute 'type'Traceback (most recent call last):
  File "/home/pschmitt/.local/share/zinit/plugins/home-assistant-ecosystem---home-assistant-cli/homeassistant_cli/cli.py", line 40, in run
    result = cli.main(standalone_mode=False)
  File "/home/pschmitt/.local/pipx/venvs/homeassistant-cli/lib/python3.10/site-packages/click/core.py", line 1050, in main
    self._main_shell_completion(extra, prog_name, complete_var)
  File "/home/pschmitt/.local/pipx/venvs/homeassistant-cli/lib/python3.10/site-packages/click/core.py", line 1125, in _main_shell_completion
    rv = shell_complete(self, ctx_args, prog_name, complete_var, instruction)
  File "/home/pschmitt/.local/pipx/venvs/homeassistant-cli/lib/python3.10/site-packages/click/shell_completion.py", line 49, in shell_complete
    echo(comp.complete())
  File "/home/pschmitt/.local/pipx/venvs/homeassistant-cli/lib/python3.10/site-packages/click/shell_completion.py", line 292, in complete
    out = [self.format_completion(item) for item in completions]
  File "/home/pschmitt/.local/pipx/venvs/homeassistant-cli/lib/python3.10/site-packages/click/shell_completion.py", line 292, in <listcomp>
    out = [self.format_completion(item) for item in completions]
  File "/home/pschmitt/.local/pipx/venvs/homeassistant-cli/lib/python3.10/site-packages/click/shell_completion.py", line 364, in format_completion
    return f"{item.type}\n{item.value}\n{item.help if item.help else '_'}

Click Completions should now return CompletionItem instances, instead of tuples.

Ref: https://github.com/pallets/click/blob/8.1.3/docs/shell-completion.rst#custom-type-completion

@pschmitt
Copy link
Contributor Author

pschmitt commented Feb 22, 2023

Have to admit that I can't figure out why the area completions test is failing 😐

EDIT: The area completion tests fail because get_areas() is a WS request that cannot be mocked by request_mock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant