From 7fdf8f148500e83058884c9a2b35f0d5bfa140c3 Mon Sep 17 00:00:00 2001 From: DaleStack <211448639+DaleStack@users.noreply.github.com> Date: Tue, 22 Jul 2025 12:52:28 +0800 Subject: [PATCH 1/2] fix: wrapped DEFAULT_HEADERS in lambda and used type(self)() in ClientOptions to retain the correct subclass --- supabase/lib/client_options.py | 4 ++-- tests/test_client_options.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/supabase/lib/client_options.py b/supabase/lib/client_options.py index ef01468b..bf9ed21b 100644 --- a/supabase/lib/client_options.py +++ b/supabase/lib/client_options.py @@ -30,7 +30,7 @@ class ClientOptions: Must be on the list of exposed schemas in Supabase. Defaults to 'public'. """ - headers: Dict[str, str] = field(default_factory=DEFAULT_HEADERS.copy) + headers: Dict[str, str] = field(default_factory=lambda: DEFAULT_HEADERS.copy) """Optional headers for initializing the client.""" auto_refresh_token: bool = True @@ -82,7 +82,7 @@ def replace( flow_type: Optional[AuthFlowType] = None, ) -> "ClientOptions": """Create a new SupabaseClientOptions with changes""" - client_options = ClientOptions() + client_options = type(self)() client_options.schema = schema or self.schema client_options.headers = headers or self.headers client_options.auto_refresh_token = ( diff --git a/tests/test_client_options.py b/tests/test_client_options.py index f35a6da7..8b6ce763 100644 --- a/tests/test_client_options.py +++ b/tests/test_client_options.py @@ -2,8 +2,7 @@ from supabase import AClientOptions, ClientOptions - -class TestClientOptions: +class TestClientOptions(): def test_replace_returns_updated_aclient_options(self): storage = SyncMemoryStorage() storage.set_item("key", "value") From a161656258f32f0e3ccb8e9bd249914a320fd2cc Mon Sep 17 00:00:00 2001 From: DaleStack <211448639+DaleStack@users.noreply.github.com> Date: Tue, 22 Jul 2025 12:55:07 +0800 Subject: [PATCH 2/2] fix: typo in test_client_options --- tests/test_client_options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_client_options.py b/tests/test_client_options.py index 8b6ce763..f30a4062 100644 --- a/tests/test_client_options.py +++ b/tests/test_client_options.py @@ -2,7 +2,7 @@ from supabase import AClientOptions, ClientOptions -class TestClientOptions(): +class TestClientOptions: def test_replace_returns_updated_aclient_options(self): storage = SyncMemoryStorage() storage.set_item("key", "value")