codenotary / immudb-py

immudb Python SDK
Apache License 2.0
43 stars 7 forks source link

Dataclasses issue when importing from immudb #68

Closed adrnsrn7 closed 10 months ago

adrnsrn7 commented 10 months ago

When deploying to lambda using serverless, there is an error with dataclasses. Upon searching, the most common solution is to remove the installation of dataclasses since it's not a necessity for python above 3.6 but deploying with serverless only gives an option to add required packages and no option to remove any. When installing immudb-py, it forces an installation of dataclasses 0.6 which is not necessary and only gives errors. Tried using python 3.8 and 3.10 with both the same results.

[ERROR] AttributeError: module 'typing' has no attribute '_ClassVar' Traceback (most recent call last): File "/var/lang/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 "/var/task/app.py", line 13, in from immudb import ImmudbClient File "/var/task/immudb/init.py", line 13, in from immudb.client import ImmudbClient File "/var/task/immudb/client.py", line 19, in from immudb import datatypes File "/var/task/immudb/datatypes.py", line 26, in class SetResponse: File "/var/task/dataclasses.py", line 958, in dataclass return wrap(_cls) File "/var/task/dataclasses.py", line 950, in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen) File "/var/task/dataclasses.py", line 800, in _process_class cls_fields = [_get_field(cls, name, type) File "/var/task/dataclasses.py", line 800, in cls_fields = [_get_field(cls, name, type) File "/var/task/dataclasses.py", line 659, in _get_field if (_is_classvar(a_type, typing) File "/var/task/dataclasses.py", line 550, in _is_classvar return type(a_type) is typing._ClassVar

SimoneLazzaris commented 10 months ago

Hi @adrnsrn7 thanks for the report. When we created immudb-py we wanted to support older python version, so we included dataclasses in the setup requirements. As you pointed out, that is not necessary with modern (3.7) python versions.

I've created a branch where that removes that packages: test/no_dataclasses. Can you try that branch? You should be able to install it with python setup.py install

adrnsrn7 commented 10 months ago

I was able to get it working by placing the new branch on my requirements.txt image So far there are no errors with both serverless framework and chalice.

Thanks for your help.