Skip to content
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.7, 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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
args: ["--fix=lf"]

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args:
Expand All @@ -35,7 +35,7 @@ repos:
]

- repo: https://github.com/psf/black
rev: "22.10.0"
rev: "23.1.0"
hooks:
- id: black

Expand Down
338 changes: 143 additions & 195 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "supabase"
version = "0.7.1"
version = "1.0.0"
description = "Supabase client for Python."
authors = ["Joel Lee <[email protected]>", "Leon Fedden <[email protected]>", "Daniel Reinón García <[email protected]>", "Leynier Gutiérrez González <[email protected]>", "Anand"]
homepage = "https://github.com/supabase-community/supabase-py"
Expand All @@ -15,12 +15,12 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.7"
postgrest-py = ">=0.10.2,<0.11.0"
realtime = "^0.0.5"
gotrue = "^0.5.0"
python = "^3.8"
postgrest-py = "0.10.3"
realtime = "^1.0.0"
gotrue = "^1.0.0"
httpx = "^0.23.0"
storage3 = ">=0.3.5,<0.5.0"
storage3 = "0.5.0"
supafunc = "^0.2.2"
python-semantic-release = "7.33.0"

Expand Down
2 changes: 1 addition & 1 deletion supabase/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.1"
__version__ = "1.0.0"
2 changes: 1 addition & 1 deletion supabase/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _init_supabase_auth_client(
url=auth_url,
auto_refresh_token=client_options.auto_refresh_token,
persist_session=client_options.persist_session,
local_storage=client_options.local_storage,
storage=client_options.storage,
headers=client_options.headers,
)

Expand Down
33 changes: 16 additions & 17 deletions supabase/lib/auth_client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from typing import Dict, Optional
from typing import Dict, Union

from gotrue import (
CookieOptions,
SyncGoTrueAPI,
SyncGoTrueClient,
SyncMemoryStorage,
SyncSupportedStorage,
)
from gotrue.constants import COOKIE_OPTIONS
from gotrue import SyncGoTrueClient, SyncMemoryStorage, SyncSupportedStorage

# TODO - export this from GoTrue-py in next release
from httpx import Client as BaseClient


class SyncClient(BaseClient):
def aclose(self) -> None:
self.close()


class SupabaseAuthClient(SyncGoTrueClient):
Expand All @@ -18,22 +19,20 @@ def __init__(
*,
url: str,
headers: Dict[str, str] = {},
storage_key: Union[str, None] = None,
auto_refresh_token: bool = True,
persist_session: bool = True,
local_storage: SyncSupportedStorage = SyncMemoryStorage(),
cookie_options: CookieOptions = CookieOptions.parse_obj(COOKIE_OPTIONS),
api: Optional[SyncGoTrueAPI] = None,
replace_default_headers: bool = False,
storage: SyncSupportedStorage = SyncMemoryStorage(),
http_client: Union[SyncClient, None] = None,
):
"""Instantiate SupabaseAuthClient instance."""
SyncGoTrueClient.__init__(
self,
url=url,
headers=headers,
storage_key=storage_key,
auto_refresh_token=auto_refresh_token,
persist_session=persist_session,
local_storage=local_storage,
cookie_options=cookie_options,
api=api,
replace_default_headers=replace_default_headers,
storage=storage,
http_client=http_client,
)
6 changes: 3 additions & 3 deletions supabase/lib/client_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ClientOptions:
persist_session: bool = True
"""Whether to persist a logged in session to storage."""

local_storage: SyncSupportedStorage = field(default_factory=SyncMemoryStorage)
storage: SyncSupportedStorage = field(default_factory=SyncMemoryStorage)
"""A storage provider. Used to store the logged in session."""

realtime: Optional[Dict[str, Any]] = None
Expand All @@ -45,7 +45,7 @@ def replace(
headers: Optional[Dict[str, str]] = None,
auto_refresh_token: Optional[bool] = None,
persist_session: Optional[bool] = None,
local_storage: Optional[SyncSupportedStorage] = None,
storage: Optional[SyncSupportedStorage] = None,
realtime: Optional[Dict[str, Any]] = None,
fetch: Optional[Callable] = None,
timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT,
Expand All @@ -58,7 +58,7 @@ def replace(
auto_refresh_token or self.auto_refresh_token
)
client_options.persist_session = persist_session or self.persist_session
client_options.local_storage = local_storage or self.local_storage
client_options.storage = storage or self.storage
client_options.realtime = realtime or self.realtime
client_options.fetch = fetch or self.fetch
client_options.timeout = timeout or self.timeout
Expand Down
20 changes: 10 additions & 10 deletions tests/test_client_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@


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

Expand All @@ -21,7 +21,7 @@ def test__client_options__replace__returns_updated_options():
headers={"key": "value"},
auto_refresh_token=False,
persist_session=False,
local_storage=local_storage,
storage=storage,
realtime={"key": "value"},
)

Expand All @@ -30,14 +30,14 @@ def test__client_options__replace__returns_updated_options():

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

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

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