Skip to content

Commit 185a149

Browse files
authored
fix: mypy supabase (#1298)
1 parent 7e3b81a commit 185a149

File tree

24 files changed

+282
-305
lines changed

24 files changed

+282
-305
lines changed

src/auth/scripts/run-unasync.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
paths = Path("src/supabase_auth").glob("**/*.py")
66
tests = Path("tests").glob("**/*.py")
77

8-
rules = (unasync._DEFAULT_RULE,)
8+
rules = (
9+
unasync.Rule(
10+
fromdir="/_async/",
11+
todir="/_sync/",
12+
additional_replacements={"AsyncClient": "Client", "aclose": "close"},
13+
),
14+
unasync._DEFAULT_RULE,
15+
)
916

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

src/auth/src/supabase_auth/_async/gotrue_admin_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
from typing import Dict, List, Optional
44

5-
from httpx import QueryParams
5+
from httpx import AsyncClient, QueryParams
66

77
from ..helpers import (
88
model_validate,
99
parse_link_response,
1010
parse_user_response,
1111
validate_uuid,
1212
)
13-
from ..http_clients import AsyncClient
1413
from ..types import (
1514
AdminUserAttributes,
1615
AuthMFAAdminDeleteFactorParams,

src/auth/src/supabase_auth/_async/gotrue_base_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
from typing import Any, Dict, Optional
44

5-
from httpx import HTTPStatusError, QueryParams, Response
5+
from httpx import AsyncClient, HTTPStatusError, QueryParams, Response
66
from pydantic import BaseModel
77
from typing_extensions import Literal, Self
88

99
from ..constants import API_VERSION_HEADER_NAME, API_VERSIONS_2024_01_01_NAME
1010
from ..helpers import handle_exception, model_dump
11-
from ..http_clients import AsyncClient
1211

1312

1413
class AsyncGoTrueBaseAPI:

src/auth/src/supabase_auth/_async/gotrue_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from urllib.parse import parse_qs, urlparse
77
from uuid import uuid4
88

9-
from httpx import QueryParams, Response
9+
from httpx import AsyncClient, QueryParams, Response
1010
from jwt import get_algorithm_by_name
1111
from typing_extensions import cast
1212

@@ -41,7 +41,6 @@
4141
parse_user_response,
4242
validate_exp,
4343
)
44-
from ..http_clients import AsyncClient
4544
from ..timer import Timer
4645
from ..types import (
4746
JWK,

src/auth/src/supabase_auth/_sync/gotrue_admin_api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
from typing import Dict, List, Optional
44

5-
from httpx import QueryParams
5+
from httpx import Client, QueryParams
66

77
from ..helpers import (
88
model_validate,
99
parse_link_response,
1010
parse_user_response,
1111
validate_uuid,
1212
)
13-
from ..http_clients import SyncClient
1413
from ..types import (
1514
AdminUserAttributes,
1615
AuthMFAAdminDeleteFactorParams,
@@ -42,7 +41,7 @@ def __init__(
4241
*,
4342
url: str = "",
4443
headers: Optional[Dict[str, str]] = None,
45-
http_client: Optional[SyncClient] = None,
44+
http_client: Optional[Client] = None,
4645
verify: bool = True,
4746
proxy: Optional[str] = None,
4847
) -> None:

src/auth/src/supabase_auth/_sync/gotrue_base_api.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
from typing import Any, Dict, Optional
44

5-
from httpx import HTTPStatusError, QueryParams, Response
5+
from httpx import Client, HTTPStatusError, QueryParams, Response
66
from pydantic import BaseModel
77
from typing_extensions import Literal, Self
88

99
from ..constants import API_VERSION_HEADER_NAME, API_VERSIONS_2024_01_01_NAME
1010
from ..helpers import handle_exception, model_dump
11-
from ..http_clients import SyncClient
1211

1312

1413
class SyncGoTrueBaseAPI:
@@ -17,13 +16,13 @@ def __init__(
1716
*,
1817
url: str,
1918
headers: Dict[str, str],
20-
http_client: Optional[SyncClient],
19+
http_client: Optional[Client],
2120
verify: bool = True,
2221
proxy: Optional[str] = None,
2322
) -> None:
2423
self._url = url
2524
self._headers = headers
26-
self._http_client = http_client or SyncClient(
25+
self._http_client = http_client or Client(
2726
verify=bool(verify),
2827
proxy=proxy,
2928
follow_redirects=True,
@@ -37,7 +36,7 @@ def __exit__(self, exc_t, exc_v, exc_tb) -> None:
3736
self.close()
3837

3938
def close(self) -> None:
40-
self._http_client.aclose()
39+
self._http_client.close()
4140

4241
def _request(
4342
self,

src/auth/src/supabase_auth/_sync/gotrue_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from urllib.parse import parse_qs, urlparse
77
from uuid import uuid4
88

9-
from httpx import QueryParams, Response
9+
from httpx import Client, QueryParams, Response
1010
from jwt import get_algorithm_by_name
1111
from typing_extensions import cast
1212

@@ -41,7 +41,6 @@
4141
parse_user_response,
4242
validate_exp,
4343
)
44-
from ..http_clients import SyncClient
4544
from ..timer import Timer
4645
from ..types import (
4746
JWK,
@@ -106,7 +105,7 @@ def __init__(
106105
auto_refresh_token: bool = True,
107106
persist_session: bool = True,
108107
storage: Optional[SyncSupportedStorage] = None,
109-
http_client: Optional[SyncClient] = None,
108+
http_client: Optional[Client] = None,
110109
flow_type: AuthFlowType = "implicit",
111110
verify: bool = True,
112111
proxy: Optional[str] = None,

src/auth/src/supabase_auth/http_clients.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/postgrest/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ help::
1212
@echo " pytest -- run pytest on postgrest package"
1313

1414
mypy:
15-
uv run --package supabase_functions mypy src/postgrest tests
15+
uv run --package postgrest mypy src/postgrest tests
1616
help::
1717
@echo " mypy -- run mypy on postgrest package"
1818

@@ -60,4 +60,4 @@ help::
6060
build:
6161
uv build --package postgrest
6262
help::
63-
@echo " build -- invoke uv build on storage3 package"
63+
@echo " build -- invoke uv build on postgrest package"

src/realtime/src/realtime/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class RealtimeChannelConfig(TypedDict):
201201

202202

203203
class RealtimeChannelOptions(TypedDict):
204-
config: RealtimeChannelConfig
204+
config: NotRequired[RealtimeChannelConfig]
205205

206206

207207
@with_config(ConfigDict(extra="allow"))

0 commit comments

Comments
 (0)