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

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

Closed
weleo opened this issue Jul 10, 2021 · 21 comments · Fixed by #353
Closed
Labels
bug Something isn't working

Comments

@weleo
Copy link

weleo commented Jul 10, 2021

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
@weleo weleo added the bug Something isn't working label Jul 10, 2021
@VRtheKing
Copy link

VRtheKing commented Jul 28, 2021

@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!

burakyilmaz321 added a commit to burakyilmaz321/fonapi-daily-ingest that referenced this issue Aug 4, 2021
@dreinon
Copy link
Contributor

dreinon commented Aug 25, 2021

@weleo were you able to deploy correctly?

@dreinon
Copy link
Contributor

dreinon commented Oct 28, 2021

@J0 we should close this issue since it seems solved.

@J0
Copy link
Contributor

J0 commented Oct 30, 2021

@weleo we are closing this due to inactivity, please let us know if you're still facing any issues.

Thanks!

@J0 J0 closed this as completed Oct 30, 2021
@la289
Copy link

la289 commented Jan 22, 2023

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

ShantanuNair added a commit to ShantanuNair/supabase-py that referenced this issue Jan 27, 2023
- Dataclasses is no longer needed. It is a dependency needed only for Python < 3.7. Realtime, however requires Python >= 3.7, and so this dep isn't needed.
  - Already removed in realtime supabase/realtime-py#48
- Fixes supabase#33 (comment) This issue comes up when using this library in AWS Lambda with serverless framework plugin serverless-python-requirements and this lock file makes it hard to deploy to Lambda with environments Python >= 3.7.
@ShantanuNair
Copy link
Contributor

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

I created a PR here #353

@J0
Copy link
Contributor

J0 commented Jan 28, 2023

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

@ShantanuNair
Copy link
Contributor

@J0 Perfect, this is a big issue causing a lot of pain in sis deploys containing supabase.

@la289
Copy link

la289 commented Jan 30, 2023

@J0 thanks a ton for addressing. Whats the timeline to a new version so that I can prepare?

@J0
Copy link
Contributor

J0 commented Jan 30, 2023

@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

@ShantanuNair
Copy link
Contributor

@J0 This is critical for us, since we are using a build time workaround for this that's proving to be unreliable. Appreciate your work!

@la289
Copy link

la289 commented Feb 1, 2023

Same^ and I will also say thanks a ton :)

@dschnabel
Copy link

dschnabel commented Feb 3, 2023

@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 supabase/realtime-py@cdb7570).

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

@J0
Copy link
Contributor

J0 commented Feb 5, 2023

Hey @dschnabel, @la289, and @ShantanuNair

Thanks for your patience with me. I've just published a new version - could I trouble you to give it a try and let me know if the issue persists?

Thanks

Jo

@la289
Copy link

la289 commented Feb 5, 2023

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

@dschnabel
Copy link

@J0 I tested it with Py3.8 and it's working! However, the API has changed with this update, but this isn't reflected in the README.

E.g. to sign up a user the new call would be:

supabase.auth.sign_up({"email": email, "password": password})

@J0
Copy link
Contributor

J0 commented Feb 7, 2023

@dschnabel good to hear - I'll update it when I get a slot! We moved everything to GoTrue v2 (like in the js lib) we'll also try to publicise it when we can

@J0
Copy link
Contributor

J0 commented Feb 7, 2023

Thanks for taking the time to reply!

@ShantanuNair
Copy link
Contributor

@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.

@dschnabel
Copy link

@ShantanuNair I think the problem with realtime was that until Friday last week no new version had been released. So when pip pulled in the dependencies it still used an old version of realtime which had the dataclasses dep. But now there's a new realtime version too, so it's enough to only define supabase in my requirements.txt.

@ShantanuNair
Copy link
Contributor

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

@dschnabel I see, okay.

greatuber pushed a commit to greatuber/supbase-py that referenced this issue Apr 18, 2024
- Dataclasses is no longer needed. It is a dependency needed only for Python < 3.7. Realtime, however requires Python >= 3.7, and so this dep isn't needed.
  - Already removed in realtime supabase/realtime-py#48
- Fixes supabase/supabase-py#33 (comment) This issue comes up when using this library in AWS Lambda with serverless framework plugin serverless-python-requirements and this lock file makes it hard to deploy to Lambda with environments Python >= 3.7.
stealthdev88 added a commit to stealthdev88/supabase-py that referenced this issue Nov 20, 2024
- Dataclasses is no longer needed. It is a dependency needed only for Python < 3.7. Realtime, however requires Python >= 3.7, and so this dep isn't needed.
  - Already removed in realtime supabase/realtime-py#48
- Fixes supabase/supabase-py#33 (comment) This issue comes up when using this library in AWS Lambda with serverless framework plugin serverless-python-requirements and this lock file makes it hard to deploy to Lambda with environments Python >= 3.7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants