supabase / supabase-py

Python Client for Supabase. Query Postgres from Flask, Django, FastAPI. Python user authentication, security policies, edge functions, file storage, and realtime data streaming. Good first issue.
https://supabase.com/docs/reference/python
MIT License
1.72k stars 203 forks source link

AsyncStorageClient.__init__() takes from 3 to 4 positional arguments but 5 were given #891

Closed michaelchen01 closed 2 months ago

michaelchen01 commented 2 months ago

Bug report

Describe the bug

Initializing the current storage client (either via a synchronous client or asynchronous client) results in this error AsyncStorageClient.__init__() takes from 3 to 4 positional arguments but 5 were given

I am initializing it according to the docs, but lmk if that's not correct. The client itself is initialized as:

self.supabase = await supabase.acreate_client(
            settings.supabase.PROJECT_URL,
            settings.supabase.ANON_KEY
        )

FWIW, I also tried with the synchronous client, and am seeing the same behavior. I've also tried deleting my virtual env + clean install and it still repros. Currently trying to figure out which version works.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Initialize any supabase client
  2. Try to access the storage client via supabase.storage at runtime.

Expected behavior

The supabase storage client should be instantiated without throwing an error.

Screenshots

More of the stack trace:

  File "<redacted>", line 359, in fetch_resource_content
    return await self.supabase.storage.from_(bucket).download(full_path)
                 ^^^^^^^^^^^^^^^^^^^^^
  File "<redacted>", line 183, in storage
    self._storage = self._init_storage_client(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<redacted>", line 242, in _init_storage_client
    return AsyncStorageClient(storage_url, headers, storage_client_timeout, verify)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncStorageClient.__init__() takes from 3 to 4 positional arguments but 5 were given

System information

Additional context

Add any other context about the problem here.

kowshik24 commented 2 months ago

Hi @michaelchen01 is there any parameter DEFAULT_STORAGE_CLIENT_TIMEOUT that you defined? While initializing the storage client?

Nikdedov commented 2 months ago

@michaelchen01 updating storage3 manually helped me, because after updating supabase, it conflicts with older storage3. As I see:

  1. Newer version of supabase try to initialise SyncStorageClient with 4 parameters: def _init_storage_client( storage_url: str, headers: Dict[str, str], storage_client_timeout: int = DEFAULT_STORAGE_CLIENT_TIMEOUT, verify: bool = True, ) -> SyncStorageClient: return SyncStorageClient(storage_url, headers, storage_client_timeout, verify)
  2. When older version of storage3 accept only 3 parameters: def __init__( self, url: str, headers: dict[str, str], timeout: int = DEFAULT_TIMEOUT, ) -> None:

    JFYI, New 'verify' parameter was added here on Jun 4, 2024

kowshik24 commented 2 months ago

gotcha!

silentworks commented 2 months ago

Yes this would be due to dependency not being updated. Update your dependencies and this should work.