supabase_functions 0.6.2__tar.gz → 0.7.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.6.2
3
+ Version: 0.7.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.6.2" # {x-release-please-version}
3
+ version = "0.7.0" # {x-release-please-version}
4
4
  description = "Library for Supabase Functions"
5
5
  authors = [
6
6
  "Joel Lee <joel@joellee.org>",
@@ -20,7 +20,7 @@ isort = "^5.12.0"
20
20
  pre-commit = ">=3.4,<5.0"
21
21
  pyjwt = "^2.8.0"
22
22
  pytest = ">=7.4.2,<9.0.0"
23
- pytest-cov = ">=4,<6"
23
+ pytest-cov = ">=4,<7"
24
24
  unasync-cli = "^0.0.9"
25
25
  pytest-asyncio = ">=0.21.1,<0.25.0"
26
26
  respx = ">=0.20.2,<0.22.0"
@@ -3,7 +3,7 @@ from typing import Any, Dict, Literal, Optional, Union
3
3
  from httpx import HTTPError, Response
4
4
 
5
5
  from ..errors import FunctionsHttpError, FunctionsRelayError
6
- from ..utils import AsyncClient
6
+ from ..utils import AsyncClient, is_http_url, is_valid_str_arg
7
7
  from ..version import __version__
8
8
 
9
9
 
@@ -16,6 +16,8 @@ class AsyncFunctionsClient:
16
16
  verify: bool = True,
17
17
  proxy: Optional[str] = None,
18
18
  ):
19
+ if not is_http_url(url):
20
+ ValueError("url must be a valid HTTP URL string")
19
21
  self.url = url
20
22
  self.headers = {
21
23
  "User-Agent": f"supabase-py/functions-py v{__version__}",
@@ -25,7 +27,7 @@ class AsyncFunctionsClient:
25
27
  base_url=self.url,
26
28
  headers=self.headers,
27
29
  verify=bool(verify),
28
- timeout=timeout,
30
+ timeout=int(abs(timeout)),
29
31
  proxy=proxy,
30
32
  follow_redirects=True,
31
33
  http2=True,
@@ -73,6 +75,8 @@ class AsyncFunctionsClient:
73
75
  `body`: the body of the request
74
76
  `responseType`: how the response should be parsed. The default is `json`
75
77
  """
78
+ if not is_valid_str_arg(function_name):
79
+ raise ValueError("function_name must a valid string value.")
76
80
  headers = self.headers
77
81
  body = None
78
82
  response_type = "text/plain"
@@ -3,7 +3,7 @@ from typing import Any, Dict, Literal, Optional, Union
3
3
  from httpx import HTTPError, Response
4
4
 
5
5
  from ..errors import FunctionsHttpError, FunctionsRelayError
6
- from ..utils import SyncClient
6
+ from ..utils import SyncClient, is_http_url, is_valid_str_arg
7
7
  from ..version import __version__
8
8
 
9
9
 
@@ -16,6 +16,8 @@ class SyncFunctionsClient:
16
16
  verify: bool = True,
17
17
  proxy: Optional[str] = None,
18
18
  ):
19
+ if not is_http_url(url):
20
+ ValueError("url must be a valid HTTP URL string")
19
21
  self.url = url
20
22
  self.headers = {
21
23
  "User-Agent": f"supabase-py/functions-py v{__version__}",
@@ -25,7 +27,7 @@ class SyncFunctionsClient:
25
27
  base_url=self.url,
26
28
  headers=self.headers,
27
29
  verify=bool(verify),
28
- timeout=timeout,
30
+ timeout=int(abs(timeout)),
29
31
  proxy=proxy,
30
32
  follow_redirects=True,
31
33
  http2=True,
@@ -73,6 +75,8 @@ class SyncFunctionsClient:
73
75
  `body`: the body of the request
74
76
  `responseType`: how the response should be parsed. The default is `json`
75
77
  """
78
+ if not is_valid_str_arg(function_name):
79
+ raise ValueError("function_name must a valid string value.")
76
80
  headers = self.headers
77
81
  body = None
78
82
  response_type = "text/plain"
@@ -0,0 +1,19 @@
1
+ from urllib.parse import urlparse
2
+
3
+ from httpx import AsyncClient as AsyncClient # noqa: F401
4
+ from httpx import Client as BaseClient
5
+
6
+ DEFAULT_FUNCTION_CLIENT_TIMEOUT = 5
7
+
8
+
9
+ class SyncClient(BaseClient):
10
+ def aclose(self) -> None:
11
+ self.close()
12
+
13
+
14
+ def is_valid_str_arg(target: str) -> bool:
15
+ return isinstance(target, str) and len(target.strip()) > 0
16
+
17
+
18
+ def is_http_url(url: str) -> bool:
19
+ return urlparse(url).scheme in {"https", "http"}
@@ -0,0 +1 @@
1
+ __version__ = "0.7.0" # {x-release-please-version}
@@ -1,9 +0,0 @@
1
- from httpx import AsyncClient as AsyncClient # noqa: F401
2
- from httpx import Client as BaseClient
3
-
4
- DEFAULT_FUNCTION_CLIENT_TIMEOUT = 5
5
-
6
-
7
- class SyncClient(BaseClient):
8
- def aclose(self) -> None:
9
- self.close()
@@ -1 +0,0 @@
1
- __version__ = "0.6.2" # {x-release-please-version}