supabase-py: [ERROR] AttributeError: module 'typing' has no attribute '_ClassVar', supabase-py on AWS Lambda

AWS Lambda returns the error below when importing supabase-py.

The error appears on runtimes: python 3.7 and 3.8.

Possibly related to the typing module as one of its dependencies.

Issues with typing Python-3 & AWS Lambda

Bug report

[ERROR] AttributeError: module 'typing' has no attribute '_ClassVar'
Traceback (most recent call last):
  File "/var/task/serverless_sdk/__init__.py", line 144, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_task.py", line 25, in error_handler
    raise e
  File "/var/task/s_task.py", line 20, in <module>
    user_handler = serverless_sdk.get_user_handler('index.handler')
  File "/var/task/serverless_sdk/__init__.py", line 56, in get_user_handler
    user_module = import_module(user_module_name)
  File "/var/lang/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/index.py", line 8, in <module>
    from supabase_py import Client, create_client
  File "/var/task/supabase_py/__init__.py", line 2, in <module>
    from . import lib
  File "/var/task/supabase_py/lib/__init__.py", line 2, in <module>
    from . import query_builder
  File "/var/task/supabase_py/lib/query_builder.py", line 8, in <module>
    from .realtime_client import SupabaseRealtimeClient
  File "/var/task/supabase_py/lib/realtime_client.py", line 3, in <module>
    from realtime_py.connection import Socket
  File "/var/task/realtime_py/__init__.py", line 2, in <module>
    from realtime_py.connection import Socket
  File "/var/task/realtime_py/connection.py", line 11, in <module>
    from realtime_py.message import HEARTBEAT_PAYLOAD, PHOENIX_CHANNEL, ChannelEvents, Message
  File "/var/task/realtime_py/message.py", line 5, in <module>
    @dataclass
  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 801, in _process_class
    for name, type in cls_annotations.items()]
  File "/var/task/dataclasses.py", line 801, in <listcomp>
    for name, type in cls_annotations.items()]
  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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Just merged, we’l publish a new version shortly. Thanks!

Can we reopen this ticket and adjust the poetry.lock file to only include dataclasses if the python version is < 3.6? Running into an issue where I’m trying to deploy the client in an AWS Lambda and I don’t have a way to uninstall dataclasses. I can’t build it with Python 3.6 runtime because then the bleach package fails to resolve

@weleo Remove a module called Dataclasses which is only supported Python versions <= 3.6. The easiest way for now is to delete the module using

pip uninstall dataclasses -y

I hope this works!

@J0 My build works just fine now, no irregular dataclasses dep is included. Thank you for the prompt version release!

@dschnabel I see, okay.

@J0 I will try building this in a few hours and update here. However @dschnabel 's issue is odd, since supabase-py dependency on realtime limits it to python 3.8+ and realtime doesn’t even have a dataclasses rep anymore. So they shouldn’t have to do anything to get it working. Regardless, I will check for my use case and let you know how it builds. Looking at the poetry.lock file it looks like things should work.

Preliminarily, I got it to build with Py3.9. Will update more soon if I have issues. Thanks!!

@J0 Yes, this is a show stopper for us as well. Thank you for a new release soon!

Edit: I just noticed that the realtime package (another supabase dependency) still requires dataclasses. This was recently removed (see https://github.com/supabase-community/realtime-py/commit/cdb7570c721a5c894f217d1deb557a04e435c1c0).

So to get it working I had to install the latest version for both modules in my requirements.txt:

git+https://github.com/supabase-community/realtime-py.git
git+https://github.com/supabase-community/supabase-py.git

@ShantanuNair great to hear that it helps @la289 probably before end of week - I’ll release it together with the changes for Supabase Auth v2. Feel free to let me know if this is for a critical project and I’ll do my best to do it sooner