Skip to content
Closed
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
4 changes: 2 additions & 2 deletions src/auth/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"httpx[http2] >=0.26,<0.29",
"httpx2>=2.12.0",
"pydantic >=1.10,<3",
"pyjwt[crypto] >=2.12.0",
]
Expand Down
2 changes: 1 addition & 1 deletion src/auth/src/supabase_auth/_async/gotrue_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Dict, List, Optional

from httpx import AsyncClient, QueryParams
from httpx2 import AsyncClient, QueryParams

from ..helpers import (
model_validate,
Expand Down
2 changes: 1 addition & 1 deletion src/auth/src/supabase_auth/_async/gotrue_base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any, Dict, Optional

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

Expand Down
4 changes: 2 additions & 2 deletions src/auth/src/supabase_auth/_async/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from uuid import uuid4
from warnings import warn

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

Expand Down Expand Up @@ -400,7 +400,7 @@ async def sign_in_with_sso(
options = credentials.get("options", {})
redirect_to = options.get("redirect_to")
captcha_token = options.get("captcha_token")
# HTTPX currently does not follow redirects: https://www.python-httpx.org/compatibility/
# HTTPX currently does not follow redirects: https://www.python-httpx2.org/compatibility/
# Additionally, unlike the JS client, Python is a server side language and it's not possible
# to automatically redirect in browser for the user
skip_http_redirect = options.get("skip_http_redirect", True)
Expand Down
2 changes: 1 addition & 1 deletion src/auth/src/supabase_auth/_sync/gotrue_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Dict, List, Optional

from httpx import Client, QueryParams
from httpx2 import Client, QueryParams

from ..helpers import (
model_validate,
Expand Down
2 changes: 1 addition & 1 deletion src/auth/src/supabase_auth/_sync/gotrue_base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any, Dict, Optional

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

Expand Down
4 changes: 2 additions & 2 deletions src/auth/src/supabase_auth/_sync/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from uuid import uuid4
from warnings import warn

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

Expand Down Expand Up @@ -398,7 +398,7 @@ def sign_in_with_sso(self, credentials: SignInWithSSOCredentials) -> SSOResponse
options = credentials.get("options", {})
redirect_to = options.get("redirect_to")
captcha_token = options.get("captcha_token")
# HTTPX currently does not follow redirects: https://www.python-httpx.org/compatibility/
# HTTPX currently does not follow redirects: https://www.python-httpx2.org/compatibility/
# Additionally, unlike the JS client, Python is a server side language and it's not possible
# to automatically redirect in browser for the user
skip_http_redirect = options.get("skip_http_redirect", True)
Expand Down
2 changes: 1 addition & 1 deletion src/auth/src/supabase_auth/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Any, Dict, Optional, Type, TypedDict, TypeVar, Union
from urllib.parse import urlparse

from httpx import HTTPStatusError, Response
from httpx2 import HTTPStatusError, Response
from pydantic import BaseModel, TypeAdapter, ValidationError

from .constants import (
Expand Down
4 changes: 2 additions & 2 deletions src/auth/tests/_async/test_gotrue.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ async def test_link_identity() -> None:

from unittest.mock import patch

from httpx import Response
from httpx2 import Response

# Since the test server has manual linking disabled, we'll mock the URL generation
with patch.object(client, "_get_url_for_provider") as mock_url_provider:
Expand Down Expand Up @@ -495,7 +495,7 @@ async def test_sign_in_with_otp() -> None:
# We can't fully test the actual OTP flow since that requires email verification
from unittest.mock import patch

from httpx import Response
from httpx2 import Response
from supabase_auth.types import AuthOtpResponse

# First test for email OTP
Expand Down
4 changes: 2 additions & 2 deletions src/auth/tests/_sync/test_gotrue.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def test_link_identity() -> None:

from unittest.mock import patch

from httpx import Response
from httpx2 import Response

# Since the test server has manual linking disabled, we'll mock the URL generation
with patch.object(client, "_get_url_for_provider") as mock_url_provider:
Expand Down Expand Up @@ -493,7 +493,7 @@ def test_sign_in_with_otp() -> None:
# We can't fully test the actual OTP flow since that requires email verification
from unittest.mock import patch

from httpx import Response
from httpx2 import Response
from supabase_auth.types import AuthOtpResponse

# First test for email OTP
Expand Down
21 changes: 12 additions & 9 deletions src/auth/tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from datetime import datetime
from unittest.mock import MagicMock, patch

import httpx
import httpx2
import pytest
import respx
from httpx import Headers, HTTPStatusError, Response
from httpx2 import Headers, HTTPStatusError, Response
from pydantic import BaseModel
from supabase_auth.constants import (
API_VERSION_HEADER_NAME,
Expand Down Expand Up @@ -47,7 +47,7 @@ def test_handle_exception_with_api_version_and_error_code() -> None:
side_effect=AuthApiError("Error code message", 400, "unexpected_failure"),
)
with pytest.raises(AuthApiError, match=r"Error code message") as exc:
httpx.get(f"{TEST_URL}/hello-world")
httpx2.get(f"{TEST_URL}/hello-world")
assert exc.value is not None
assert exc.value.message == "Error code message"
assert exc.value.code == err["code"]
Expand All @@ -69,7 +69,7 @@ def test_handle_exception_without_api_version_and_weak_password_error_code() ->
),
)
with pytest.raises(AuthWeakPasswordError, match=r"Error code message") as exc:
httpx.get(f"{TEST_URL}/hello-world")
httpx2.get(f"{TEST_URL}/hello-world")
assert exc.value is not None
assert exc.value.message == "Error code message"
assert exc.value.code == err["code"]
Expand All @@ -89,7 +89,7 @@ def test_handle_exception_with_api_version_2024_01_01_and_error_code() -> None:
side_effect=AuthApiError("Error code message", 400, "unexpected_failure"),
)
with pytest.raises(AuthApiError, match=r"Error code message") as exc:
httpx.get(f"{TEST_URL}/hello-world")
httpx2.get(f"{TEST_URL}/hello-world")
assert exc.value is not None
assert exc.value.message == "Error code message"
assert exc.value.code == err["code"]
Expand Down Expand Up @@ -337,12 +337,15 @@ def test_handle_exception_weak_password_branch() -> None:
This test attempts to test the branch where weak_password needs to be both a dict and a list,
which is logically impossible, so we'll test it by mocking the implementation details.
"""
import httpx
try:
import httpx2 as httpx2
except ImportError:
import httpx2
from supabase_auth.errors import AuthWeakPasswordError
from supabase_auth.helpers import handle_exception

# Create a proper mock Response with headers
mock_response = MagicMock(spec=httpx.Response)
mock_response = MagicMock(spec=httpx2.Response)
mock_response.status_code = 400
mock_response.headers = {}

Expand All @@ -359,8 +362,8 @@ def __init__(self, *args, **kwargs) -> None:
}

# Create a proper HTTPStatusError
exception = httpx.HTTPStatusError(
"Password error", request=MagicMock(spec=httpx.Request), response=mock_response
exception = httpx2.HTTPStatusError(
"Password error", request=MagicMock(spec=httpx2.Request), response=mock_response
)

# We need to directly target the specific branch handling weak passwords
Expand Down
4 changes: 2 additions & 2 deletions src/functions/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ maintainers = [
]
license = "MIT"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"httpx[http2] >=0.26,<0.29",
"httpx2>=2.12.0",
"strenum >=0.4.15",
"yarl>=1.20.1",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Dict, Literal, Optional, Union
from warnings import warn

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

from ..errors import FunctionsHttpError, FunctionsRelayError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Dict, Literal, Optional, Union
from warnings import warn

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

from ..errors import FunctionsHttpError, FunctionsRelayError
Expand Down
2 changes: 1 addition & 1 deletion src/functions/src/supabase_functions/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from urllib.parse import urlparse

from httpx import AsyncClient as AsyncClient # noqa: F401
from httpx2 import AsyncClient as AsyncClient # noqa: F401

if sys.version_info >= (3, 11):
from enum import StrEnum
Expand Down
6 changes: 3 additions & 3 deletions src/functions/tests/_async/test_function_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import AsyncMock, Mock, patch

import pytest
from httpx import AsyncClient, HTTPError, Response, Timeout
from httpx2 import AsyncClient, HTTPError, Response, Timeout

# Import the class to test
from supabase_functions import AsyncFunctionsClient
Expand Down Expand Up @@ -207,13 +207,13 @@ async def test_invoke_with_json_body(client: AsyncFunctionsClient) -> None:


async def test_init_with_httpx_client() -> None:
# Create a custom httpx client with specific options
# Create a custom httpx2 client with specific options
headers = {"x-user-agent": "my-app/0.0.1"}
custom_client = AsyncClient(
timeout=Timeout(30), follow_redirects=True, max_redirects=5, headers=headers
)

# Initialize the functions client with the custom httpx client
# Initialize the functions client with the custom httpx2 client
client = AsyncFunctionsClient(
url="https://example.com",
headers={"Authorization": "Bearer token"},
Expand Down
6 changes: 3 additions & 3 deletions src/functions/tests/_sync/test_function_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import Mock, patch

import pytest
from httpx import Client, HTTPError, Response, Timeout
from httpx2 import Client, HTTPError, Response, Timeout

# Import the class to test
from supabase_functions import SyncFunctionsClient
Expand Down Expand Up @@ -191,13 +191,13 @@ def test_invoke_with_json_body(client: SyncFunctionsClient) -> None:


def test_init_with_httpx_client() -> None:
# Create a custom httpx client with specific options
# Create a custom httpx2 client with specific options
headers = {"x-user-agent": "my-app/0.0.1"}
custom_client = Client(
timeout=Timeout(30), follow_redirects=True, max_redirects=5, headers=headers
)

# Initialize the functions client with the custom httpx client
# Initialize the functions client with the custom httpx2 client
client = SyncFunctionsClient(
url="https://example.com",
headers={"Authorization": "Bearer token"},
Expand Down
4 changes: 2 additions & 2 deletions src/postgrest/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"
]
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"httpx[http2] >=0.26,<0.29",
"httpx2>=2.12.0",
"deprecation >=2.1.0",
"pydantic >=1.9,<3.0",
"strenum >=0.4.9; python_version < \"3.11\"",
Expand Down
2 changes: 1 addition & 1 deletion src/postgrest/src/postgrest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from httpx import Timeout
from httpx2 import Timeout

from ._async.client import AsyncPostgrestClient
from ._async.request_builder import (
Expand Down
2 changes: 1 addition & 1 deletion src/postgrest/src/postgrest/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from warnings import warn

from deprecation import deprecated
from httpx import AsyncClient, Headers, QueryParams, Timeout
from httpx2 import AsyncClient, Headers, QueryParams, Timeout
from yarl import URL

from ..base_client import BasePostgrestClient
Expand Down
2 changes: 1 addition & 1 deletion src/postgrest/src/postgrest/_async/request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
from typing import Any, Generic, Literal, Optional, TypeVar, Union, overload

from httpx import AsyncClient, BasicAuth, Headers, QueryParams, Response
from httpx2 import AsyncClient, BasicAuth, Headers, QueryParams, Response
from pydantic import ValidationError
from typing_extensions import Self, override
from yarl import URL
Expand Down
2 changes: 1 addition & 1 deletion src/postgrest/src/postgrest/_sync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from warnings import warn

from deprecation import deprecated
from httpx import Client, Headers, QueryParams, Timeout
from httpx2 import Client, Headers, QueryParams, Timeout
from yarl import URL

from ..base_client import BasePostgrestClient
Expand Down
2 changes: 1 addition & 1 deletion src/postgrest/src/postgrest/_sync/request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import time
from typing import Any, Generic, Literal, Optional, TypeVar, Union, overload

from httpx import BasicAuth, Client, Headers, QueryParams, Response
from httpx2 import BasicAuth, Client, Headers, QueryParams, Response
from pydantic import ValidationError
from typing_extensions import Self, override
from yarl import URL
Expand Down
2 changes: 1 addition & 1 deletion src/postgrest/src/postgrest/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from abc import ABC, abstractmethod
from typing import Dict, Optional, Union

from httpx import AsyncClient, BasicAuth, Client, Headers, Timeout
from httpx2 import AsyncClient, BasicAuth, Client, Headers, Timeout
from yarl import URL

from .utils import is_http_url
Expand Down
4 changes: 2 additions & 2 deletions src/postgrest/src/postgrest/base_request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
overload,
)

from httpx import AsyncClient, BasicAuth, Client, Headers, QueryParams
from httpx import Response as RequestResponse
from httpx2 import AsyncClient, BasicAuth, Client, Headers, QueryParams
from httpx2 import Response as RequestResponse
from pydantic import BaseModel, ValidationError
from yarl import URL

Expand Down
2 changes: 1 addition & 1 deletion src/postgrest/src/postgrest/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections.abc import Mapping, Sequence
from typing import Union

from httpx import AsyncClient, BasicAuth, Client, Headers, QueryParams
from httpx2 import AsyncClient, BasicAuth, Client, Headers, QueryParams
from pydantic import TypeAdapter
from typing_extensions import TypeAliasType
from yarl import URL
Expand Down
Loading