Async_test_home_assistant.<locals>.async_create_task() takes 1 positional argument but 2 were given

Hello, since I update my env dev this day with latest Home Assistant release 2023.3.1 my dev environment is broken.

I’ve got this error:

hass = <homeassistant.core.HomeAssistant object at 0xffff896da950>
domain = 'versatile_thermostat'
config = {'_': 'Not empty or else some bad checks for hass config in discovery.py breaks'}

    async def async_setup_component(
        hass: core.HomeAssistant, domain: str, config: ConfigType
    ) -> bool:
        """Set up a component and all its dependencies.
    
        This method is a coroutine.
        """
        if domain in hass.config.components:
            return True
    
        setup_tasks: dict[str, asyncio.Task[bool]] = hass.data.setdefault(DATA_SETUP, {})
    
        if domain in setup_tasks:
            return await setup_tasks[domain]
    
>       task = setup_tasks[domain] = hass.async_create_task(
            _async_setup_component(hass, domain, config), f"setup component {domain}"
        )
E       TypeError: async_test_home_assistant.<locals>.async_create_task() takes 1 positional argument but 2 were given

homeassistant/setup.py:95: TypeError

And I can’t get rid of this error. I try to reinstall previous release but without success. I try to update pytest-homeassistant-custom-component without success too.

What is really strange is that the hass.async_create_task() function takes 2 arguments.

Any help would be appreciated.

Note: this error only appears when I run unit test (pytest). If I start the server normally I have got no errors.

The above package needs to be updated for the latest core changes

That’s what I do with release 0.13.5 which seems to be the last:

$ pip install pytest-homeassistant-custom-component==0.13.5

vscode ➜ /workspaces/core (dev) $ pip index versions pytest-homeassistant-custom-component
pytest-homeassistant-custom-component (0.13.5)
Available versions: 0.13.5, 0.13.4, 0.13.3, 0.13.2, 0.13.1, 0.13.0, 0.12.57, 0.12.56, 0.12.55, 0.12.54, 0.12.53, 0.12.52, 0.12.51, 0.12.50, 0.12.49, 0.12.48, 0.12.47, 0.12.46, 0.12.45, 0.12.44, 0.12.43, 0.12.42, 0.12.41, 0.12.40, 0.12.39, 0.12.38, 0.12.37, 0.12.36, 0.12.35, 0.12.34, 0.12.33, 0.12.32, 0.12.31, 0.12.30, 0.12.29, 0.12.28, 0.12.27, 0.12.26, 0.12.25, 0.12.24, 0.12.23, 0.12.22, 0.12.21, 0.12.20, 0.12.19, 0.12.18, ...
  INSTALLED: 0.13.5
  LATEST:    0.13.5
$ pip index versions homeassistant
homeassistant (2023.3.1)
Available versions: 2023.3.1, 2023.3.0, 2023.2.5, 2023.2.4, 2023.2.3, 2023.2.2, 2023.2.1, 2023.2.0, 2023.1.7, 2023.1.6, 2023.1.5, 2023.1.4, 2023.1.3, 2023.1.2, 2023.1.1, 2023.1.0, 2022.12.9, 2022.12.8, 
...
  INSTALLED: 2023.3.1
  LATEST:    2023.3.1

I try to rebuild the container after installation but without success.

I found this error at container startup:

Installing collected packages: coverage, pre-commit, pytest
  Attempting uninstall: coverage
    Found existing installation: coverage 7.1.0
    Uninstalling coverage-7.1.0:
      Successfully uninstalled coverage-7.1.0
  Attempting uninstall: pre-commit
    Found existing installation: pre-commit 3.1.1
    Uninstalling pre-commit-3.1.1:
      Successfully uninstalled pre-commit-3.1.1
  Attempting uninstall: pytest
    Found existing installation: pytest 7.2.1
    Uninstalling pytest-7.2.1:
      Successfully uninstalled pytest-7.2.1
ERROR: pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
pytest-homeassistant-custom-component 0.13.5 requires coverage==7.1.0, but you'll have coverage 7.2.1 which is incompatible.
pytest-homeassistant-custom-component 0.13.5 requires pytest==7.2.1, but you'll have pytest 7.2.2 which is incompatible.
Successfully installed coverage-7.2.1 pre-commit-3.1.0 pytest-7.2.2

Fixing pytest and coverage with 7.2.1 and 7.1.0 doesn’t change anything.

For clarity, it’s not you that needs to update yet, it’s the code in the repo that needs to be updated

1 Like

Ah ok thanks. So I have to revert back but I try without success. I will re-try rollback more precisely.

Ok I finally found that those releases should be compatible but my homeassistant release was the in “dev” branch and this is not more compatible. I switch back 2023.3.1 core release.

Thanks @bdraco that helps me a lot.