11from dataclasses import dataclass , field
2- from typing import Any , Callable , Dict , Optional
2+ from typing import Any , Callable , Dict , Optional , Union
33
44from gotrue import SyncMemoryStorage , SyncSupportedStorage
5+ from httpx import Timeout
6+ from postgrest .constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
57
68from supabase import __version__
79
@@ -34,6 +36,9 @@ class ClientOptions:
3436 fetch : Optional [Callable ] = None
3537 """A custom `fetch` implementation."""
3638
39+ timeout : Union [int , float , Timeout ] = DEFAULT_POSTGREST_CLIENT_TIMEOUT
40+ """Timeout passed to the SyncPostgrestClient instance."""
41+
3742 def replace (
3843 self ,
3944 schema : Optional [str ] = None ,
@@ -43,6 +48,7 @@ def replace(
4348 local_storage : Optional [SyncSupportedStorage ] = None ,
4449 realtime : Optional [Dict [str , Any ]] = None ,
4550 fetch : Optional [Callable ] = None ,
51+ timeout : Union [int , float , Timeout ] = DEFAULT_POSTGREST_CLIENT_TIMEOUT ,
4652 ) -> "ClientOptions" :
4753 """Create a new SupabaseClientOptions with changes"""
4854 client_options = ClientOptions ()
@@ -55,4 +61,5 @@ def replace(
5561 client_options .local_storage = local_storage or self .local_storage
5662 client_options .realtime = realtime or self .realtime
5763 client_options .fetch = fetch or self .fetch
64+ client_options .timeout = timeout or self .timeout
5865 return client_options
0 commit comments