supabase_functions 0.9.4__tar.gz → 0.10.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supabase_functions
3
- Version: 0.9.4
3
+ Version: 0.10.0
4
4
  Summary: Library for Supabase Functions
5
5
  Home-page: https://github.com/supabase/functions-py
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "supabase_functions"
3
- version = "0.9.4" # {x-release-please-version}
3
+ version = "0.10.0" # {x-release-please-version}
4
4
  description = "Library for Supabase Functions"
5
5
  authors = [
6
6
  "Joel Lee <joel@joellee.org>",
@@ -23,12 +23,15 @@ pyjwt = "^2.8.0"
23
23
  pytest = ">=7.4.2,<9.0.0"
24
24
  pytest-cov = ">=4,<7"
25
25
  unasync-cli = "^0.0.9"
26
- pytest-asyncio = ">=0.21.1,<0.26.0"
26
+ pytest-asyncio = ">=0.21.1,<1.1.0"
27
27
  coveralls = "^3.3.0"
28
28
 
29
29
  [tool.pytest.ini_options]
30
30
  asyncio_mode = "auto"
31
31
  addopts = "tests"
32
+ filterwarnings = [
33
+ "ignore::DeprecationWarning", # ignore deprecation warnings globally
34
+ ]
32
35
 
33
36
  [build-system]
34
37
  requires = ["poetry-core>=1.0.0"]
@@ -1,12 +1,17 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Literal, Optional, Union, overload
3
+ from typing import Literal, Union, overload
4
4
 
5
5
  from ._async.functions_client import AsyncFunctionsClient
6
6
  from ._sync.functions_client import SyncFunctionsClient
7
7
  from .utils import FunctionRegion
8
8
 
9
- __all__ = ["create_client"]
9
+ __all__ = [
10
+ "create_client",
11
+ "FunctionRegion",
12
+ "AsyncFunctionsClient",
13
+ "SyncFunctionsClient",
14
+ ]
10
15
 
11
16
 
12
17
  @overload
@@ -1,11 +1,10 @@
1
1
  from typing import Any, Dict, Literal, Optional, Union
2
2
  from warnings import warn
3
3
 
4
- from httpx import HTTPError, Response
4
+ from httpx import AsyncClient, HTTPError, Response
5
5
 
6
6
  from ..errors import FunctionsHttpError, FunctionsRelayError
7
7
  from ..utils import (
8
- AsyncClient,
9
8
  FunctionRegion,
10
9
  is_http_url,
11
10
  is_valid_jwt,
@@ -19,9 +18,10 @@ class AsyncFunctionsClient:
19
18
  self,
20
19
  url: str,
21
20
  headers: Dict,
22
- timeout: int,
23
- verify: bool = True,
21
+ timeout: Optional[int] = None,
22
+ verify: Optional[bool] = None,
24
23
  proxy: Optional[str] = None,
24
+ http_client: Optional[AsyncClient] = None,
25
25
  ):
26
26
  if not is_http_url(url):
27
27
  raise ValueError("url must be a valid HTTP URL string")
@@ -30,15 +30,43 @@ class AsyncFunctionsClient:
30
30
  "User-Agent": f"supabase-py/functions-py v{__version__}",
31
31
  **headers,
32
32
  }
33
- self._client = AsyncClient(
34
- base_url=self.url,
35
- headers=self.headers,
36
- verify=bool(verify),
37
- timeout=int(abs(timeout)),
38
- proxy=proxy,
39
- follow_redirects=True,
40
- http2=True,
41
- )
33
+
34
+ if timeout is not None:
35
+ warn(
36
+ "The 'timeout' parameter is deprecated. Please configure it in the http client instead.",
37
+ DeprecationWarning,
38
+ stacklevel=2,
39
+ )
40
+ if verify is not None:
41
+ warn(
42
+ "The 'verify' parameter is deprecated. Please configure it in the http client instead.",
43
+ DeprecationWarning,
44
+ stacklevel=2,
45
+ )
46
+ if proxy is not None:
47
+ warn(
48
+ "The 'proxy' parameter is deprecated. Please configure it in the http client instead.",
49
+ DeprecationWarning,
50
+ stacklevel=2,
51
+ )
52
+
53
+ self.verify = bool(verify) if verify is not None else True
54
+ self.timeout = int(abs(timeout)) if timeout is not None else 60
55
+
56
+ if http_client is not None:
57
+ http_client.base_url = self.url
58
+ http_client.headers.update({**self.headers})
59
+ self._client = http_client
60
+ else:
61
+ self._client = AsyncClient(
62
+ base_url=self.url,
63
+ headers=self.headers,
64
+ verify=self.verify,
65
+ timeout=self.timeout,
66
+ proxy=proxy,
67
+ follow_redirects=True,
68
+ http2=True,
69
+ )
42
70
 
43
71
  async def _request(
44
72
  self,
@@ -1,12 +1,11 @@
1
1
  from typing import Any, Dict, Literal, Optional, Union
2
2
  from warnings import warn
3
3
 
4
- from httpx import HTTPError, Response
4
+ from httpx import Client, HTTPError, Response
5
5
 
6
6
  from ..errors import FunctionsHttpError, FunctionsRelayError
7
7
  from ..utils import (
8
8
  FunctionRegion,
9
- SyncClient,
10
9
  is_http_url,
11
10
  is_valid_jwt,
12
11
  is_valid_str_arg,
@@ -19,9 +18,10 @@ class SyncFunctionsClient:
19
18
  self,
20
19
  url: str,
21
20
  headers: Dict,
22
- timeout: int,
23
- verify: bool = True,
21
+ timeout: Optional[int] = None,
22
+ verify: Optional[bool] = None,
24
23
  proxy: Optional[str] = None,
24
+ http_client: Optional[Client] = None,
25
25
  ):
26
26
  if not is_http_url(url):
27
27
  raise ValueError("url must be a valid HTTP URL string")
@@ -30,15 +30,43 @@ class SyncFunctionsClient:
30
30
  "User-Agent": f"supabase-py/functions-py v{__version__}",
31
31
  **headers,
32
32
  }
33
- self._client = SyncClient(
34
- base_url=self.url,
35
- headers=self.headers,
36
- verify=bool(verify),
37
- timeout=int(abs(timeout)),
38
- proxy=proxy,
39
- follow_redirects=True,
40
- http2=True,
41
- )
33
+
34
+ if timeout is not None:
35
+ warn(
36
+ "The 'timeout' parameter is deprecated. Please configure it in the http client instead.",
37
+ DeprecationWarning,
38
+ stacklevel=2,
39
+ )
40
+ if verify is not None:
41
+ warn(
42
+ "The 'verify' parameter is deprecated. Please configure it in the http client instead.",
43
+ DeprecationWarning,
44
+ stacklevel=2,
45
+ )
46
+ if proxy is not None:
47
+ warn(
48
+ "The 'proxy' parameter is deprecated. Please configure it in the http client instead.",
49
+ DeprecationWarning,
50
+ stacklevel=2,
51
+ )
52
+
53
+ self.verify = bool(verify) if verify is not None else True
54
+ self.timeout = int(abs(timeout)) if timeout is not None else 60
55
+
56
+ if http_client is not None:
57
+ http_client.base_url = self.url
58
+ http_client.headers.update({**self.headers})
59
+ self._client = http_client
60
+ else:
61
+ self._client = Client(
62
+ base_url=self.url,
63
+ headers=self.headers,
64
+ verify=self.verify,
65
+ timeout=self.timeout,
66
+ proxy=proxy,
67
+ follow_redirects=True,
68
+ http2=True,
69
+ )
42
70
 
43
71
  def _request(
44
72
  self,
@@ -1,6 +1,7 @@
1
1
  import re
2
2
  import sys
3
3
  from urllib.parse import urlparse
4
+ from warnings import warn
4
5
 
5
6
  from httpx import AsyncClient as AsyncClient # noqa: F401
6
7
  from httpx import Client as BaseClient
@@ -34,7 +35,21 @@ class FunctionRegion(StrEnum):
34
35
 
35
36
 
36
37
  class SyncClient(BaseClient):
38
+ def __init__(self, *args, **kwargs):
39
+ warn(
40
+ "The 'SyncClient' class is deprecated. Please use `Client` from the httpx package instead.",
41
+ DeprecationWarning,
42
+ stacklevel=2,
43
+ )
44
+
45
+ super().__init__(*args, **kwargs)
46
+
37
47
  def aclose(self) -> None:
48
+ warn(
49
+ "The 'aclose' method is deprecated. Please use `close` method from `Client` in the httpx package instead.",
50
+ DeprecationWarning,
51
+ stacklevel=2,
52
+ )
38
53
  self.close()
39
54
 
40
55
 
@@ -0,0 +1 @@
1
+ __version__ = "0.10.0" # {x-release-please-version}
@@ -1 +0,0 @@
1
- __version__ = "0.9.4" # {x-release-please-version}