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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ help::
@echo " stop-infra -- Stop all infra used by tests."
@echo " NOTE: run this command to ensure all containers are stopped after tests"

mypy: $(call FORALL_PKGS,mypy)
help::
@echo " mypy -- Run mypy on all files"

ruff:
@uv run ruff check --fix
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,28 @@ supabase = { workspace = true }

[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.ruff]
target-version = "py39"

[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"]

[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true
23 changes: 0 additions & 23 deletions src/auth/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,6 @@ lints = [
]
dev = [{ include-group = "lints" }, {include-group = "tests" }]

[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"]

[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true


[tool.pytest.ini_options]
asyncio_mode = "auto"

Expand Down
3 changes: 1 addition & 2 deletions src/auth/tests/_async/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

from faker import Faker
from jwt import encode
from typing_extensions import NotRequired, TypedDict

from supabase_auth import AsyncGoTrueAdminAPI, AsyncGoTrueClient
from supabase_auth.types import User
from typing_extensions import NotRequired, TypedDict


def mock_access_token() -> str:
Expand Down
2 changes: 0 additions & 2 deletions src/auth/tests/_async/test_gotrue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pytest
from jwt import encode

from supabase_auth.errors import (
AuthApiError,
AuthInvalidJwtError,
Expand Down Expand Up @@ -489,7 +488,6 @@ async def test_sign_in_with_otp() -> None:
from unittest.mock import patch

from httpx import Response

from supabase_auth.types import AuthOtpResponse

# First test for email OTP
Expand Down
1 change: 0 additions & 1 deletion src/auth/tests/_async/test_gotrue_admin_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import uuid

import pytest

from supabase_auth.errors import (
AuthApiError,
AuthError,
Expand Down
3 changes: 1 addition & 2 deletions src/auth/tests/_sync/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

from faker import Faker
from jwt import encode
from typing_extensions import NotRequired, TypedDict

from supabase_auth import SyncGoTrueAdminAPI, SyncGoTrueClient
from supabase_auth.types import User
from typing_extensions import NotRequired, TypedDict


def mock_access_token() -> str:
Expand Down
2 changes: 0 additions & 2 deletions src/auth/tests/_sync/test_gotrue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pytest
from jwt import encode

from supabase_auth.errors import (
AuthApiError,
AuthInvalidJwtError,
Expand Down Expand Up @@ -487,7 +486,6 @@ def test_sign_in_with_otp() -> None:
from unittest.mock import patch

from httpx import Response

from supabase_auth.types import AuthOtpResponse

# First test for email OTP
Expand Down
1 change: 0 additions & 1 deletion src/auth/tests/_sync/test_gotrue_admin_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import uuid

import pytest

from supabase_auth.errors import (
AuthApiError,
AuthError,
Expand Down
2 changes: 0 additions & 2 deletions src/auth/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import respx
from httpx import Headers, HTTPStatusError, Response
from pydantic import BaseModel

from supabase_auth.constants import (
API_VERSION_HEADER_NAME,
)
Expand Down Expand Up @@ -339,7 +338,6 @@ def test_handle_exception_weak_password_branch() -> None:
which is logically impossible, so we'll test it by mocking the implementation details.
"""
import httpx

from supabase_auth.errors import AuthWeakPasswordError
from supabase_auth.helpers import handle_exception

Expand Down
4 changes: 2 additions & 2 deletions src/functions/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_test_failed_incremental: Dict[str, Dict[Tuple[int, ...], str]] = {}


def pytest_runtest_makereport(item, call):
def pytest_runtest_makereport(item, call) -> None:
if "incremental" in item.keywords:
# incremental marker is used
if call.excinfo is not None:
Expand All @@ -29,7 +29,7 @@ def pytest_runtest_makereport(item, call):
)


def pytest_runtest_setup(item):
def pytest_runtest_setup(item) -> None:
if "incremental" in item.keywords:
# retrieve the class name of the test
cls_name = str(item.cls)
Expand Down
3 changes: 2 additions & 1 deletion src/functions/run-unasync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unasync
from pathlib import Path

import unasync

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Dict, Literal, Optional, Union
from warnings import warn

from httpx import AsyncClient, HTTPError, Response, QueryParams
from httpx import AsyncClient, HTTPError, QueryParams, Response
from yarl import URL

from ..errors import FunctionsHttpError, FunctionsRelayError
Expand All @@ -22,7 +22,7 @@ def __init__(
verify: Optional[bool] = None,
proxy: Optional[str] = None,
http_client: Optional[AsyncClient] = None,
):
) -> None:
if not is_http_url(url):
raise ValueError("url must be a valid HTTP URL string")
self.url = URL(url)
Expand Down Expand Up @@ -133,7 +133,7 @@ async def invoke(
region = invoke_options.get("region")
if region:
if not isinstance(region, FunctionRegion):
warn(f"Use FunctionRegion({region})")
warn(f"Use FunctionRegion({region})", stacklevel=2)
region = FunctionRegion(region)

if region.value != "any":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Dict, Literal, Optional, Union
from warnings import warn

from httpx import Client, HTTPError, Response, QueryParams
from httpx import Client, HTTPError, QueryParams, Response
from yarl import URL

from ..errors import FunctionsHttpError, FunctionsRelayError
Expand All @@ -22,7 +22,7 @@ def __init__(
verify: Optional[bool] = None,
proxy: Optional[str] = None,
http_client: Optional[Client] = None,
):
) -> None:
if not is_http_url(url):
raise ValueError("url must be a valid HTTP URL string")
self.url = URL(url)
Expand Down Expand Up @@ -133,7 +133,7 @@ def invoke(
region = invoke_options.get("region")
if region:
if not isinstance(region, FunctionRegion):
warn(f"Use FunctionRegion({region})")
warn(f"Use FunctionRegion({region})", stacklevel=2)
region = FunctionRegion(region)

if region.value != "any":
Expand Down
21 changes: 0 additions & 21 deletions src/functions/src/supabase_functions/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import sys
from urllib.parse import urlparse
from warnings import warn

from httpx import AsyncClient as AsyncClient # noqa: F401
from httpx import Client as BaseClient

if sys.version_info >= (3, 11):
from enum import StrEnum
Expand Down Expand Up @@ -33,25 +31,6 @@ class FunctionRegion(StrEnum):
UsWest2 = "us-west-2"


class SyncClient(BaseClient):
def __init__(self, *args, **kwargs):
warn(
"The 'SyncClient' class is deprecated. Please use `Client` from the httpx package instead.",
DeprecationWarning,
stacklevel=2,
)

super().__init__(*args, **kwargs)

def aclose(self) -> None:
warn(
"The 'aclose' method is deprecated. Please use `close` method from `Client` in the httpx package instead.",
DeprecationWarning,
stacklevel=2,
)
self.close()


def is_valid_str_arg(target: str) -> bool:
return isinstance(target, str) and len(target.strip()) > 0

Expand Down
Loading