home-assistant-ecosystem / home-assistant-cli

:computer: Command-line tool for Home Assistant
Other
437 stars 68 forks source link

unexpected keyword argument 'autocompletion' #384

Closed r0oland closed 2 years ago

r0oland commented 2 years ago

Machine / Install

No matter what I try, when running hass-cli info I get the following error message:

  File "C:\Users\johan\mambaforge\envs\HA\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\johan\mambaforge\envs\HA\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\johan\mambaforge\envs\HA\Scripts\hass-cli.exe\__main__.py", line 4, in <module>
  File "C:\Users\johan\mambaforge\envs\HA\lib\site-packages\homeassistant_cli\cli.py", line 209, in <module>
    def cli(
  File "C:\Users\johan\mambaforge\envs\HA\lib\site-packages\click\decorators.py", line 308, in decorator
    _param_memo(f, OptionClass(param_decls, **option_attrs))
  File "C:\Users\johan\mambaforge\envs\HA\lib\site-packages\click\core.py", line 2495, in __init__
    super().__init__(param_decls, type=type, multiple=multiple, **attrs)
TypeError: Parameter.__init__() got an unexpected keyword argument 'autocompletion'
r0oland commented 2 years ago

I just tried this on my WSL with Ubuntu and Python 3.8.10 with the same error message.

reeseovine commented 2 years ago

I'm getting this error too on Manjaro Linux, with both the pip package and the AUR package.

Traceback ```  hass-cli info Traceback (most recent call last): File "/usr/bin/hass-cli", line 33, in sys.exit(load_entry_point('homeassistant-cli==0.9.4', 'console_scripts', 'hass-cli')()) File "/usr/bin/hass-cli", line 25, in importlib_load_entry_point return next(matches).load() File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load module = import_module(match.group('module')) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/usr/lib/python3.10/site-packages/homeassistant_cli/cli.py", line 210, in def cli( File "/home/reese/.local/lib/python3.10/site-packages/click/decorators.py", line 308, in decorator _param_memo(f, OptionClass(param_decls, **option_attrs)) File "/home/reese/.local/lib/python3.10/site-packages/click/core.py", line 2495, in __init__ super().__init__(param_decls, type=type, multiple=multiple, **attrs) TypeError: Parameter.__init__() got an unexpected keyword argument 'autocompletion' ```
ScottG489 commented 2 years ago

Also getting this on Ubuntu 21.04 installing via pip install homeassistant-cli or sudo pip install homeassistant-cli.

Found a workaround: pip3 install click==8.0.4

Nevertheless this is still a valid issue.

unhandyman commented 2 years ago

Installed python-homeassistant-cli 0.9.4-1 on Arch Linux via AUR. Downgrading from python-click 8.1.3-1 to python-click-8.0.4-1 did not help:

Traceback

```bash $ hass-cli info error: HomeAssistantCliError: Unexpected error retrieving information Run with -x to see full exception information $ hass-cli -x info Unexpected error retrieving information Traceback (most recent call last): File "/home/flo/.local/lib/python3.10/site-packages/urllib3/connection.py", line 159, in _new_conn conn = connection.create_connection( File "/home/flo/.local/lib/python3.10/site-packages/urllib3/util/connection.py", line 61, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/flo/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 670, in urlopen httplib_response = self._make_request( File "/home/flo/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 381, in _make_request self._validate_conn(conn) File "/home/flo/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn conn.connect() File "/home/flo/.local/lib/python3.10/site-packages/urllib3/connection.py", line 309, in connect conn = self._new_conn() File "/home/flo/.local/lib/python3.10/site-packages/urllib3/connection.py", line 171, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno -2] Name or service not known During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/flo/.local/lib/python3.10/site-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/home/flo/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 726, in urlopen retries = retries.increment( File "/home/flo/.local/lib/python3.10/site-packages/urllib3/util/retry.py", line 446, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='homeassistant.local', port=8123): Max retries exceeded with url: /api/discovery_info (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -2] Name or service not known')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/homeassistant_cli/remote.py", line 78, in restapi return requests.get(url, params=data_str, headers=headers) File "/home/flo/.local/lib/python3.10/site-packages/requests/api.py", line 76, in get return request('get', url, params=params, **kwargs) File "/home/flo/.local/lib/python3.10/site-packages/requests/api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "/home/flo/.local/lib/python3.10/site-packages/requests/sessions.py", line 530, in request resp = self.send(prep, **send_kwargs) File "/home/flo/.local/lib/python3.10/site-packages/requests/sessions.py", line 643, in send r = adapter.send(request, **kwargs) File "/home/flo/.local/lib/python3.10/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='homeassistant.local', port=8123): Max retries exceeded with url: /api/discovery_info (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -2] Name or service not known')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/homeassistant_cli/remote.py", line 314, in get_info req = restapi(ctx, METH_GET, hass.URL_API_DISCOVERY_INFO) File "/usr/lib/python3.10/site-packages/homeassistant_cli/remote.py", line 83, in restapi raise HomeAssistantCliError(f"Error connecting to {url}") homeassistant_cli.exceptions.HomeAssistantCliError: Error connecting to https://homeassistant.local:8123/api/discovery_info During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/homeassistant_cli/cli.py", line 40, in run result = cli.main(standalone_mode=False) File "/usr/lib/python3.10/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/usr/lib/python3.10/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/lib/python3.10/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/lib/python3.10/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/usr/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "/usr/lib/python3.10/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/usr/lib/python3.10/site-packages/homeassistant_cli/plugins/info.py", line 28, in cli [api.get_info(ctx)], File "/usr/lib/python3.10/site-packages/homeassistant_cli/remote.py", line 323, in get_info raise HomeAssistantCliError("Unexpected error retrieving information") homeassistant_cli.exceptions.HomeAssistantCliError: Unexpected error retrieving information ```

Also, when setting this up as mentioned in the README there was an error regarding the completion command:

$ source <(hass-cli completion zsh)
Usage: hass-cli [OPTIONS] COMMAND [ARGS]...
Try 'hass-cli --help' for help.

Error: No such command 'completion'.
ScottG489 commented 2 years ago

Same as @unhandyman. I'm also getting that error from running that completion setup command.

joshuaspence commented 2 years ago

@unhandyman Try _HASS_CLI_COMPLETE=zsh_source hass-cli completion instead

unhandyman commented 2 years ago

Sorry for the delay. This does unfortunately not solve the problem.

$ _HASS_CLI_COMPLETE=zsh_source hass-cli completion
Traceback (most recent call last):
  File "/usr/bin/hass-cli", line 33, in <module>
    sys.exit(load_entry_point('homeassistant-cli==0.9.4', 'console_scripts', 'hass-cli')())
  File "/usr/bin/hass-cli", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/homeassistant_cli/cli.py", line 210, in <module>
    def cli(
  File "/usr/lib/python3.10/site-packages/click/decorators.py", line 308, in decorator
    _param_memo(f, OptionClass(param_decls, **option_attrs))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 2495, in __init__
    super().__init__(param_decls, type=type, multiple=multiple, **attrs)
TypeError: Parameter.__init__() got an unexpected keyword argument 'autocompletion'
ScottG489 commented 2 years ago

@joshuaspence Thanks, this worked for me and I've put the following in my ~/.zshrc:

source <(_HASS_CLI_COMPLETE=zsh_source hass-cli completion zsh)
jpnadas commented 2 years ago

@fabaff could you maybe take a look at my PR (#385)? It solves this issue.