zwave-js-server-python icon indicating copy to clipboard operation
zwave-js-server-python copied to clipboard

Pydantic 2 does not support all of the V1 capabilities

Open chrand opened this issue 2 years ago • 5 comments

hello. Trying to launch zwave-js-server-python, but it terminates with import error. Install was done with pip3 install zwave-js-server-python Launching it, I get the error below:

$ ./zwave-js-server-python
Traceback (most recent call last):
  File "./zwave-js-server-python", line 5, in <module>
    from zwave_js_server.__main__ import main
  File "/home/chr/.local/lib/python3.8/site-packages/zwave_js_server/__main__.py", line 9, in <module>
    from .client import Client
  File "/home/chr/.local/lib/python3.8/site-packages/zwave_js_server/client.py", line 28, in <module>
    from .model.driver import Driver
  File "/home/chr/.local/lib/python3.8/site-packages/zwave_js_server/model/driver.py", line 4, in <module>
    from pydantic import create_model_from_typeddict
  File "/home/chr/.local/lib/python3.8/site-packages/pydantic/__init__.py", line 218, in __getattr__
    return _getattr_migration(attr_name)
  File "/home/chr/.local/lib/python3.8/site-packages/pydantic/_migration.py", line 300, in wrapper
    raise PydanticImportError(f'`{import_path}` has been removed in V2.')
pydantic.errors.PydanticImportError: `pydantic:create_model_from_typeddict` has been removed in V2.

For further information visit https://errors.pydantic.dev/2.4/u/import-error

chrand avatar Oct 14 '23 19:10 chrand

Downgrade pydantic to 1.10 and everything should work as is. Thanks for the report though, maybe we aren't as ready for pydantic 2 as we thought

raman325 avatar Oct 15 '23 02:10 raman325

np. happy to have helped testing. thanks for a nice client library!

chrand avatar Oct 15 '23 20:10 chrand

It seems like its available in the v1 shims, so that is surprising:

$ pip3 install pydantic==2.4.2
$ python3
>>> from pydantic.v1 import create_model_from_typeddict
>>> 

allenporter avatar Oct 16 '23 04:10 allenporter

hmm that's weird. @chrand is it possible you were on an earlier version of v2 that didn't have this shim?

raman325 avatar Oct 16 '23 04:10 raman325

Is this just an older version of zwave-js-server-python without the shims? Seems like it could be based on the line numbers.

Edit: Yeah, would be helpful to know version of zwave-js-server-python and pydantic involved

allenporter avatar Oct 16 '23 04:10 allenporter