Skip to content

fix: use correct default factory for headers and preserve subclass types in replace() #1180

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions supabase/lib/client_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = (
Expand Down
1 change: 0 additions & 1 deletion tests/test_client_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from supabase import AClientOptions, ClientOptions


class TestClientOptions:
def test_replace_returns_updated_aclient_options(self):
storage = SyncMemoryStorage()
Expand Down