Skip to content
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
9 changes: 8 additions & 1 deletion src/auth/scripts/run-unasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
paths = Path("src/supabase_auth").glob("**/*.py")
tests = Path("tests").glob("**/*.py")

rules = (unasync._DEFAULT_RULE,)
rules = (
unasync.Rule(
fromdir="/_async/",
todir="/_sync/",
additional_replacements={"AsyncClient": "Client", "aclose": "close"},
),
unasync._DEFAULT_RULE,
)

files = [str(p) for p in list(paths) + list(tests)]

Expand Down
3 changes: 1 addition & 2 deletions src/auth/src/supabase_auth/_async/gotrue_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

from typing import Dict, List, Optional

from httpx import QueryParams
from httpx import AsyncClient, QueryParams

from ..helpers import (
model_validate,
parse_link_response,
parse_user_response,
validate_uuid,
)
from ..http_clients import AsyncClient
from ..types import (
AdminUserAttributes,
AuthMFAAdminDeleteFactorParams,
Expand Down
3 changes: 1 addition & 2 deletions src/auth/src/supabase_auth/_async/gotrue_base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

from typing import Any, Dict, Optional

from httpx import HTTPStatusError, QueryParams, Response
from httpx import AsyncClient, HTTPStatusError, QueryParams, Response
from pydantic import BaseModel
from typing_extensions import Literal, Self

from ..constants import API_VERSION_HEADER_NAME, API_VERSIONS_2024_01_01_NAME
from ..helpers import handle_exception, model_dump
from ..http_clients import AsyncClient


class AsyncGoTrueBaseAPI:
Expand Down
3 changes: 1 addition & 2 deletions src/auth/src/supabase_auth/_async/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from urllib.parse import parse_qs, urlparse
from uuid import uuid4

from httpx import QueryParams, Response
from httpx import AsyncClient, QueryParams, Response
from jwt import get_algorithm_by_name
from typing_extensions import cast

Expand Down Expand Up @@ -41,7 +41,6 @@
parse_user_response,
validate_exp,
)
from ..http_clients import AsyncClient
from ..timer import Timer
from ..types import (
JWK,
Expand Down
5 changes: 2 additions & 3 deletions src/auth/src/supabase_auth/_sync/gotrue_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

from typing import Dict, List, Optional

from httpx import QueryParams
from httpx import Client, QueryParams

from ..helpers import (
model_validate,
parse_link_response,
parse_user_response,
validate_uuid,
)
from ..http_clients import SyncClient
from ..types import (
AdminUserAttributes,
AuthMFAAdminDeleteFactorParams,
Expand Down Expand Up @@ -42,7 +41,7 @@ def __init__(
*,
url: str = "",
headers: Optional[Dict[str, str]] = None,
http_client: Optional[SyncClient] = None,
http_client: Optional[Client] = None,
verify: bool = True,
proxy: Optional[str] = None,
) -> None:
Expand Down
9 changes: 4 additions & 5 deletions src/auth/src/supabase_auth/_sync/gotrue_base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

from typing import Any, Dict, Optional

from httpx import HTTPStatusError, QueryParams, Response
from httpx import Client, HTTPStatusError, QueryParams, Response
from pydantic import BaseModel
from typing_extensions import Literal, Self

from ..constants import API_VERSION_HEADER_NAME, API_VERSIONS_2024_01_01_NAME
from ..helpers import handle_exception, model_dump
from ..http_clients import SyncClient


class SyncGoTrueBaseAPI:
Expand All @@ -17,13 +16,13 @@ def __init__(
*,
url: str,
headers: Dict[str, str],
http_client: Optional[SyncClient],
http_client: Optional[Client],
verify: bool = True,
proxy: Optional[str] = None,
) -> None:
self._url = url
self._headers = headers
self._http_client = http_client or SyncClient(
self._http_client = http_client or Client(
verify=bool(verify),
proxy=proxy,
follow_redirects=True,
Expand All @@ -37,7 +36,7 @@ def __exit__(self, exc_t, exc_v, exc_tb) -> None:
self.close()

def close(self) -> None:
self._http_client.aclose()
self._http_client.close()

def _request(
self,
Expand Down
5 changes: 2 additions & 3 deletions src/auth/src/supabase_auth/_sync/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from urllib.parse import parse_qs, urlparse
from uuid import uuid4

from httpx import QueryParams, Response
from httpx import Client, QueryParams, Response
from jwt import get_algorithm_by_name
from typing_extensions import cast

Expand Down Expand Up @@ -41,7 +41,6 @@
parse_user_response,
validate_exp,
)
from ..http_clients import SyncClient
from ..timer import Timer
from ..types import (
JWK,
Expand Down Expand Up @@ -106,7 +105,7 @@ def __init__(
auto_refresh_token: bool = True,
persist_session: bool = True,
storage: Optional[SyncSupportedStorage] = None,
http_client: Optional[SyncClient] = None,
http_client: Optional[Client] = None,
flow_type: AuthFlowType = "implicit",
verify: bool = True,
proxy: Optional[str] = None,
Expand Down
9 changes: 0 additions & 9 deletions src/auth/src/supabase_auth/http_clients.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/postgrest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ help::
@echo " pytest -- run pytest on postgrest package"

mypy:
uv run --package supabase_functions mypy src/postgrest tests
uv run --package postgrest mypy src/postgrest tests
help::
@echo " mypy -- run mypy on postgrest package"

Expand Down Expand Up @@ -60,4 +60,4 @@ help::
build:
uv build --package postgrest
help::
@echo " build -- invoke uv build on storage3 package"
@echo " build -- invoke uv build on postgrest package"
2 changes: 1 addition & 1 deletion src/realtime/src/realtime/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class RealtimeChannelConfig(TypedDict):


class RealtimeChannelOptions(TypedDict):
config: RealtimeChannelConfig
config: NotRequired[RealtimeChannelConfig]


@with_config(ConfigDict(extra="allow"))
Expand Down
24 changes: 22 additions & 2 deletions src/supabase/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
.PHONY: pytest pre-commit unasync build-sync tests

help::
@echo "Available commands"
@echo " help -- (default) print this message"

tests: pytest
help::
@echo " tests -- run all tests for supabase package"

pytest:
uv run --package supabase pytest --cov=./ --cov-report=xml --cov-report=html -vv
help::
@echo " pytest -- run pytest on supabase package"

mypy:
uv run --package supabase mypy src/supabase tests
help::
@echo " mypy -- run mypy on supabase package"


unasync:
uv run run-unasync.py
Expand All @@ -14,12 +30,16 @@ build-sync: unasync
sed -i 's/SyncClient/Client/gi' tests/_sync/test_client.py
sed -i 's/SyncHTTPTransport/HTTPTransport/g' tests/_sync/test_client.py
sed -i 's/SyncMock/Mock/g' tests/_sync/test_client.py

tests: pytest
help::
@echo " build-sync -- generate _sync from _async implementation"

clean:
rm -rf htmlcov .pytest_cache .mypy_cache .ruff_cache
rm -f .coverage coverage.xml
help::
@echo " clean -- clean intermediary files generated by tests"

build:
uv build --package supabase
help::
@echo " build -- invoke uv build on supabase package"
19 changes: 19 additions & 0 deletions src/supabase/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ lints = [
[tool.uv]
default-groups = [ "dev" ]

[tool.ruff.lint]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
# "SIM",
# isort
"I",
"ANN2"
]
ignore = ["F403", "E501", "E402", "UP006", "UP035"]


[build-system]
requires = ["uv_build>=0.8.3,<0.9.0"]
build-backend = "uv_build"
12 changes: 10 additions & 2 deletions src/supabase/run-unasync.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import unasync
from pathlib import Path

import unasync

paths = Path("src/supabase").glob("**/*.py")
tests = Path("tests").glob("**/*.py")

rules = (unasync._DEFAULT_RULE,)
rules = (
unasync.Rule(
fromdir="/_async/",
todir="/_sync/",
additional_replacements={"AsyncClient": "Client"},
),
unasync._DEFAULT_RULE,
)

files = [str(p) for p in list(paths) + list(tests)]

Expand Down
12 changes: 5 additions & 7 deletions src/supabase/src/supabase/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from postgrest import APIError as PostgrestAPIError
from postgrest import APIResponse as PostgrestAPIResponse
from realtime import AuthorizationError, NotConnectedError
from storage3.utils import StorageException
from supabase_auth.errors import (
AuthApiError,
AuthError,
Expand All @@ -8,10 +12,6 @@
AuthUnknownError,
AuthWeakPasswordError,
)
from postgrest import APIError as PostgrestAPIError
from postgrest import APIResponse as PostgrestAPIResponse
from realtime import AuthorizationError, NotConnectedError
from storage3.utils import StorageException
from supabase_functions.errors import (
FunctionsError,
FunctionsHttpError,
Expand All @@ -30,11 +30,9 @@

# Sync Client
from ._sync.auth_client import SyncSupabaseAuthClient as SupabaseAuthClient
from ._sync.client import SupabaseException
from ._sync.client import Client, SupabaseException, create_client
from ._sync.client import SupabaseException as SyncSupabaseException
from ._sync.client import SyncClient as Client
from ._sync.client import SyncStorageClient as SupabaseStorageClient
from ._sync.client import create_client

# Lib
from .lib.client_options import AsyncClientOptions
Expand Down
7 changes: 3 additions & 4 deletions src/supabase/src/supabase/_async/auth_client.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import Dict, Optional

from httpx import AsyncClient
from supabase_auth import (
AsyncGoTrueClient,
AsyncMemoryStorage,
AsyncSupportedStorage,
AuthFlowType,
)
from supabase_auth.http_clients import AsyncClient


class AsyncSupabaseAuthClient(AsyncGoTrueClient):
Expand All @@ -20,12 +19,12 @@ def __init__(
storage_key: Optional[str] = None,
auto_refresh_token: bool = True,
persist_session: bool = True,
storage: AsyncSupportedStorage = AsyncMemoryStorage(),
storage: Optional[AsyncSupportedStorage] = None,
http_client: Optional[AsyncClient] = None,
flow_type: AuthFlowType = "implicit",
verify: bool = True,
proxy: Optional[str] = None,
):
) -> None:
"""
Instantiate a SupabaseAuthClient instance.

Expand Down
Loading