Skip to content

Commit e5fc57a

Browse files
authored
Merge pull request #471 from Ananya2001-an/chore-typing
chore: fixed some types
2 parents 8e341c7 + c0da631 commit e5fc57a

File tree

4 files changed

+50
-47
lines changed

4 files changed

+50
-47
lines changed

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest]
11-
python-version: [3.8, 3.9, "3.10", "3.11"]
11+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- name: Clone Repository

Diff for: supabase/client.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ def __init__(
5959
self.supabase_url = supabase_url
6060
self.supabase_key = supabase_key
6161
options.headers.update(self._get_auth_headers())
62-
self.rest_url: str = f"{supabase_url}/rest/v1"
63-
self.realtime_url: str = f"{supabase_url}/realtime/v1".replace("http", "ws")
64-
self.auth_url: str = f"{supabase_url}/auth/v1"
62+
self.rest_url = f"{supabase_url}/rest/v1"
63+
self.realtime_url = f"{supabase_url}/realtime/v1".replace("http", "ws")
64+
self.auth_url = f"{supabase_url}/auth/v1"
6565
self.storage_url = f"{supabase_url}/storage/v1"
6666
self.functions_url = f"{supabase_url}/functions/v1"
67-
self.schema: str = options.schema
67+
self.schema = options.schema
6868

6969
# Instantiate clients.
7070
self.auth = self._init_supabase_auth_client(

Diff for: supabase/lib/auth_client.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, Union
1+
from typing import Dict, Optional
22

33
from gotrue import SyncGoTrueClient, SyncMemoryStorage, SyncSupportedStorage
44

@@ -18,14 +18,17 @@ def __init__(
1818
self,
1919
*,
2020
url: str,
21-
headers: Dict[str, str] = {},
22-
storage_key: Union[str, None] = None,
21+
headers: Optional[Dict[str, str]] = None,
22+
storage_key: Optional[str] = None,
2323
auto_refresh_token: bool = True,
2424
persist_session: bool = True,
2525
storage: SyncSupportedStorage = SyncMemoryStorage(),
26-
http_client: Union[SyncClient, None] = None,
26+
http_client: Optional[SyncClient] = None,
2727
):
2828
"""Instantiate SupabaseAuthClient instance."""
29+
if headers is None:
30+
headers = {}
31+
2932
SyncGoTrueClient.__init__(
3033
self,
3134
url=url,

Diff for: tests/test_client_options.py

+38-38
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,41 @@
33
from supabase.lib.client_options import ClientOptions
44

55

6-
def test__client_options__replace__returns_updated_options():
7-
storage = SyncMemoryStorage()
8-
storage.set_item("key", "value")
9-
options = ClientOptions(
10-
schema="schema",
11-
headers={"key": "value"},
12-
auto_refresh_token=False,
13-
persist_session=False,
14-
storage=storage,
15-
realtime={"key": "value"},
16-
)
17-
18-
actual = options.replace(schema="new schema")
19-
expected = ClientOptions(
20-
schema="new schema",
21-
headers={"key": "value"},
22-
auto_refresh_token=False,
23-
persist_session=False,
24-
storage=storage,
25-
realtime={"key": "value"},
26-
)
27-
28-
assert actual == expected
29-
30-
31-
def test__client_options__replace__updates_only_new_options():
32-
# Arrange
33-
storage = SyncMemoryStorage()
34-
storage.set_item("key", "value")
35-
options = ClientOptions(storage=storage)
36-
new_options = options.replace()
37-
38-
# Act
39-
new_options.storage.set_item("key", "new_value")
40-
41-
# Assert
42-
assert options.storage.get_item("key") == "new_value"
43-
assert new_options.storage.get_item("key") == "new_value"
6+
class TestClientOptions:
7+
def test_replace_returns_updated_options(self):
8+
storage = SyncMemoryStorage()
9+
storage.set_item("key", "value")
10+
options = ClientOptions(
11+
schema="schema",
12+
headers={"key": "value"},
13+
auto_refresh_token=False,
14+
persist_session=False,
15+
storage=storage,
16+
realtime={"key": "value"},
17+
)
18+
19+
actual = options.replace(schema="new schema")
20+
expected = ClientOptions(
21+
schema="new schema",
22+
headers={"key": "value"},
23+
auto_refresh_token=False,
24+
persist_session=False,
25+
storage=storage,
26+
realtime={"key": "value"},
27+
)
28+
29+
assert actual == expected
30+
31+
def test_replace_updates_only_new_options(self):
32+
# Arrange
33+
storage = SyncMemoryStorage()
34+
storage.set_item("key", "value")
35+
options = ClientOptions(storage=storage)
36+
new_options = options.replace()
37+
38+
# Act
39+
new_options.storage.set_item("key", "new_value")
40+
41+
# Assert
42+
assert options.storage.get_item("key") == "new_value"
43+
assert new_options.storage.get_item("key") == "new_value"

0 commit comments

Comments
 (0)