Skip to content

chore: fixed some types #471

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

Merged
merged 1 commit into from
Jun 19, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ${{ matrix.os }}
steps:
- name: Clone Repository
Expand Down
8 changes: 4 additions & 4 deletions supabase/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def __init__(
self.supabase_url = supabase_url
self.supabase_key = supabase_key
options.headers.update(self._get_auth_headers())
self.rest_url: str = f"{supabase_url}/rest/v1"
self.realtime_url: str = f"{supabase_url}/realtime/v1".replace("http", "ws")
self.auth_url: str = f"{supabase_url}/auth/v1"
self.rest_url = f"{supabase_url}/rest/v1"
self.realtime_url = f"{supabase_url}/realtime/v1".replace("http", "ws")
self.auth_url = f"{supabase_url}/auth/v1"
self.storage_url = f"{supabase_url}/storage/v1"
self.functions_url = f"{supabase_url}/functions/v1"
self.schema: str = options.schema
self.schema = options.schema

# Instantiate clients.
self.auth = self._init_supabase_auth_client(
Expand Down
11 changes: 7 additions & 4 deletions supabase/lib/auth_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Union
from typing import Dict, Optional

from gotrue import SyncGoTrueClient, SyncMemoryStorage, SyncSupportedStorage

Expand All @@ -18,14 +18,17 @@ def __init__(
self,
*,
url: str,
headers: Dict[str, str] = {},
storage_key: Union[str, None] = None,
headers: Optional[Dict[str, str]] = None,
storage_key: Optional[str] = None,
auto_refresh_token: bool = True,
persist_session: bool = True,
storage: SyncSupportedStorage = SyncMemoryStorage(),
http_client: Union[SyncClient, None] = None,
http_client: Optional[SyncClient] = None,
):
"""Instantiate SupabaseAuthClient instance."""
if headers is None:
headers = {}

SyncGoTrueClient.__init__(
self,
url=url,
Expand Down
76 changes: 38 additions & 38 deletions tests/test_client_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
from supabase.lib.client_options import ClientOptions


def test__client_options__replace__returns_updated_options():
storage = SyncMemoryStorage()
storage.set_item("key", "value")
options = ClientOptions(
schema="schema",
headers={"key": "value"},
auto_refresh_token=False,
persist_session=False,
storage=storage,
realtime={"key": "value"},
)

actual = options.replace(schema="new schema")
expected = ClientOptions(
schema="new schema",
headers={"key": "value"},
auto_refresh_token=False,
persist_session=False,
storage=storage,
realtime={"key": "value"},
)

assert actual == expected


def test__client_options__replace__updates_only_new_options():
# Arrange
storage = SyncMemoryStorage()
storage.set_item("key", "value")
options = ClientOptions(storage=storage)
new_options = options.replace()

# Act
new_options.storage.set_item("key", "new_value")

# Assert
assert options.storage.get_item("key") == "new_value"
assert new_options.storage.get_item("key") == "new_value"
class TestClientOptions:
def test_replace_returns_updated_options(self):
storage = SyncMemoryStorage()
storage.set_item("key", "value")
options = ClientOptions(
schema="schema",
headers={"key": "value"},
auto_refresh_token=False,
persist_session=False,
storage=storage,
realtime={"key": "value"},
)

actual = options.replace(schema="new schema")
expected = ClientOptions(
schema="new schema",
headers={"key": "value"},
auto_refresh_token=False,
persist_session=False,
storage=storage,
realtime={"key": "value"},
)

assert actual == expected

def test_replace_updates_only_new_options(self):
# Arrange
storage = SyncMemoryStorage()
storage.set_item("key", "value")
options = ClientOptions(storage=storage)
new_options = options.replace()

# Act
new_options.storage.set_item("key", "new_value")

# Assert
assert options.storage.get_item("key") == "new_value"
assert new_options.storage.get_item("key") == "new_value"