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

HA fails to load zwave_js, pydantic says "TypeError: Argument 'bases' has incorrect type (expected list, got tuple)" #101525

Closed
tanuva opened this issue Oct 6, 2023 · 8 comments

Comments

@tanuva
Copy link

tanuva commented Oct 6, 2023

The problem

Home Assistant fails to load the zwave_js extension because pydantic is unhappy (see Python traceback in the respective field below).

What version of Home Assistant Core has the issue?

core-2023.10.0

What was the last working version of Home Assistant Core?

core-2023.05.x (the last one I got working on Debian 11)

What type of installation are you running?

Home Assistant Core

Integration causing the issue

zwave_js

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zwave_js/

Diagnostics information

home-assistant_2023-10-06T10-14-27.889Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.loader
Source: loader.py:818
First occurred: 12:01:26 (1 occurrences)
Last logged: 12:01:26

Unexpected exception importing component homeassistant.components.zwave_js
Traceback (most recent call last):
  File "/srv/homeassistant/py3.11/lib/python3.11/site-packages/homeassistant/loader.py", line 818, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/srv/homeassistant/py3.11/lib/python3.11/site-packages/homeassistant/components/zwave_js/__init__.py", line 11, in <module>
    from zwave_js_server.client import Client as ZwaveClient
  File "/srv/homeassistant/py3.11/lib/python3.11/site-packages/zwave_js_server/client.py", line 26, in <module>
    from .event import Event
  File "/srv/homeassistant/py3.11/lib/python3.11/site-packages/zwave_js_server/event.py", line 16, in <module>
    class BaseEventModel(BaseModel):
  File "pydantic/main.py", line 186, in pydantic.main.ModelMetaclass.__new__
TypeError: Argument 'bases' has incorrect type (expected list, got tuple)

Additional information

@home-assistant
Copy link

home-assistant bot commented Oct 6, 2023

Hey there @home-assistant/z-wave, mind taking a look at this issue as it has been labeled with an integration (zwave_js) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zwave_js can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign zwave_js Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


zwave_js documentation
zwave_js source
(message by IssueLinks)

@frenck
Copy link
Member

frenck commented Oct 6, 2023

Seems like you are running a newer version of Pydantic than was pinned in the Home Assistant project, or, looks like you have cython 3 in your Python environment, which has a known issue with Pydantic at this point (see: pydantic/pydantic#7689)

../Frenck

@tanuva
Copy link
Author

tanuva commented Oct 6, 2023

That's strange. I found the issue report for pydantic, too, but so far I don't see where that would be coming into my setup. As mentioned in the description, I have the pydantic version that HA prefers:

(py3.11) homeassistant@idefix:/srv/homeassistant$ pip show pydantic
Name: pydantic
Version: 1.10.12
Summary: Data validation and settings management using python type hints
Home-page: https://github.com/pydantic/pydantic
Author: Samuel Colvin
Author-email: s@muelcolvin.com
License: MIT
Location: /srv/homeassistant/py3.11/lib/python3.11/site-packages
Requires: typing-extensions
Required-by: zwave-js-server-python

(The "py3.11" portion of the prompt is the virtualenv name.)

...and at least as far as I can tell I don't have Cython installed. Neither pip nor aptitude know anything about that:

(py3.11) homeassistant@idefix:/srv/homeassistant$ pip show Cython
WARNING: Package(s) not found: Cython
pi@idefix:~ $ aptitude show cython3
Package: cython3                         
Version: 0.29.32-2+b1
New: yes
State: not installed
[...]

@ALaDoffe
Copy link

ALaDoffe commented Oct 6, 2023

As Workaround, after testing several versions of pydantic, my HA running well with pydantic 1.10.10

$ pip install pydantic==1.10.10
$ python -c "import pydantic.utils; print(pydantic.utils.version_info())"
pydantic version: 1.10.10
pydantic compiled: False
install path: /srv/homeassistant/lib/python3.11/site-packages/pydantic
python version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
platform: Linux-6.1.55-v7+-armv7l-with-glibc2.36
optional deps. installed: ['typing-extensions']

@tanuva
Copy link
Author

tanuva commented Oct 6, 2023

Good find! pydantic 1.10.10 works for me, too. So I suspect HA may need to be pinned to that version instead? 🤔 (At least until pydantic is fixed, that is.)

@tgkspike
Copy link

tgkspike commented Oct 7, 2023

As Workaround, after testing several versions of pydantic, my HA running well with pydantic 1.10.10

$ pip install pydantic==1.10.10 $ python -c "import pydantic.utils; print(pydantic.utils.version_info())" pydantic version: 1.10.10 pydantic compiled: False install path: /srv/homeassistant/lib/python3.11/site-packages/pydantic python version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] platform: Linux-6.1.55-v7+-armv7l-with-glibc2.36 optional deps. installed: ['typing-extensions']

Sorry for the newbie question but are you able to direct me on how / where I would go about rolling back to pydantic 1.10.10 so I could use this fix for the short term? (I see the code above but have no idea where this would go) , using raspberry pi3, home assistant core-2023.10.1

@ALaDoffe
Copy link

ALaDoffe commented Oct 8, 2023

Found a solution to have pydantic-1.10.12 working as HA requirement.
Installing package from GIT source !!!

Stop HA

$ sudo -u homeassistant -s -H
$ source /YOURVENVPATH/bin/activate
$ cd $HOME
$ mkdir install-pydantic
$ cd install-pydantic
$ wget https://github.com/pydantic/pydantic/archive/refs/tags/v1.10.12.zip
$ unzip v1.10.12.zip
$ pip install ./pydantic-1.10.12
$ python -c "import pydantic.utils; print(pydantic.utils.version_info())"
pydantic version: 1.10.12
pydantic compiled: False
install path: /srv/homeassistant/lib/python3.11/site-packages/pydantic
python version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
platform: Linux-6.1.55-v7+-armv7l-with-glibc2.36
optional deps. installed: ['typing-extensions']
$ cd $HOME
$ rm -rf install-pydantic

Start HA

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@issue-triage-workflows issue-triage-workflows bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants