Skip to content

Commit

Permalink
fix: add "verify" flag to the creation of client
Browse files Browse the repository at this point in the history
  • Loading branch information
juancarlospaco authored Jun 5, 2024
1 parent 66c3c1a commit f43038c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
14 changes: 9 additions & 5 deletions supabase_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@

@overload
def create_client(
url: str, headers: dict[str, str], *, is_async: Literal[True]
url: str, headers: dict[str, str], *, is_async: Literal[True], verify: bool
) -> AsyncFunctionsClient: ...


@overload
def create_client(
url: str, headers: dict[str, str], *, is_async: Literal[False]
url: str, headers: dict[str, str], *, is_async: Literal[False], verify: bool
) -> SyncFunctionsClient: ...


def create_client(
url: str, headers: dict[str, str], *, is_async: bool
url: str,
headers: dict[str, str],
*,
is_async: bool,
verify: bool = True,
) -> Union[AsyncFunctionsClient, SyncFunctionsClient]:
if is_async:
return AsyncFunctionsClient(url, headers)
return AsyncFunctionsClient(url, headers, verify)
else:
return SyncFunctionsClient(url, headers)
return SyncFunctionsClient(url, headers, verify)
7 changes: 5 additions & 2 deletions supabase_functions/_async/functions_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@


class AsyncFunctionsClient:
def __init__(self, url: str, headers: Dict):
def __init__(self, url: str, headers: Dict, verify: bool = True):
self.url = url
self.headers = {
"User-Agent": f"supabase-py/functions-py v{__version__}",
**headers,
}
self._client = AsyncClient(
base_url=self.url, headers=self.headers, follow_redirects=True
base_url=self.url,
headers=self.headers,
verify=bool(verify),
follow_redirects=True,
)

async def _request(
Expand Down
7 changes: 5 additions & 2 deletions supabase_functions/_sync/functions_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@


class SyncFunctionsClient:
def __init__(self, url: str, headers: Dict):
def __init__(self, url: str, headers: Dict, verify: bool = True):
self.url = url
self.headers = {
"User-Agent": f"supabase-py/functions-py v{__version__}",
**headers,
}
self._client = SyncClient(
base_url=self.url, headers=self.headers, follow_redirects=True
base_url=self.url,
headers=self.headers,
verify=bool(verify),
follow_redirects=True,
)

def _request(
Expand Down

0 comments on commit f43038c

Please sign in to comment.