Skip to content

Commit c36d80f

Browse files
fix: Types to use Option[T] (#960)
1 parent fce8839 commit c36d80f

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

Diff for: supabase/_async/client.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(
3434
self,
3535
supabase_url: str,
3636
supabase_key: str,
37-
options: Union[ClientOptions, None] = None,
37+
options: Optional[ClientOptions] = None,
3838
):
3939
"""Instantiate the client.
4040
@@ -97,7 +97,7 @@ async def create(
9797
cls,
9898
supabase_url: str,
9999
supabase_key: str,
100-
options: Union[ClientOptions, None] = None,
100+
options: Optional[ClientOptions] = None,
101101
):
102102
auth_header = options.headers.get("Authorization") if options else None
103103
client = cls(supabase_url, supabase_key, options)
@@ -278,9 +278,7 @@ def _init_postgrest_client(
278278
def _create_auth_header(self, token: str):
279279
return f"Bearer {token}"
280280

281-
def _get_auth_headers(
282-
self, authorization: Union[str, None] = None
283-
) -> Dict[str, str]:
281+
def _get_auth_headers(self, authorization: Optional[str] = None) -> Dict[str, str]:
284282
if authorization is None:
285283
authorization = self.options.headers.get(
286284
"Authorization", self._create_auth_header(self.supabase_key)
@@ -293,7 +291,7 @@ def _get_auth_headers(
293291
}
294292

295293
def _listen_to_auth_events(
296-
self, event: AuthChangeEvent, session: Union[Session, None]
294+
self, event: AuthChangeEvent, session: Optional[Session]
297295
):
298296
access_token = self.supabase_key
299297
if event in ["SIGNED_IN", "TOKEN_REFRESHED", "SIGNED_OUT"]:
@@ -310,7 +308,7 @@ def _listen_to_auth_events(
310308
async def create_client(
311309
supabase_url: str,
312310
supabase_key: str,
313-
options: Union[ClientOptions, None] = None,
311+
options: Optional[ClientOptions] = None,
314312
) -> AsyncClient:
315313
"""Create client function to instantiate supabase client like JS runtime.
316314

Diff for: supabase/_sync/client.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(
3333
self,
3434
supabase_url: str,
3535
supabase_key: str,
36-
options: Union[ClientOptions, None] = None,
36+
options: Optional[ClientOptions] = None,
3737
):
3838
"""Instantiate the client.
3939
@@ -96,7 +96,7 @@ def create(
9696
cls,
9797
supabase_url: str,
9898
supabase_key: str,
99-
options: Union[ClientOptions, None] = None,
99+
options: Optional[ClientOptions] = None,
100100
):
101101
auth_header = options.headers.get("Authorization") if options else None
102102
client = cls(supabase_url, supabase_key, options)
@@ -277,9 +277,7 @@ def _init_postgrest_client(
277277
def _create_auth_header(self, token: str):
278278
return f"Bearer {token}"
279279

280-
def _get_auth_headers(
281-
self, authorization: Union[str, None] = None
282-
) -> Dict[str, str]:
280+
def _get_auth_headers(self, authorization: Optional[str] = None) -> Dict[str, str]:
283281
if authorization is None:
284282
authorization = self.options.headers.get(
285283
"Authorization", self._create_auth_header(self.supabase_key)
@@ -292,7 +290,7 @@ def _get_auth_headers(
292290
}
293291

294292
def _listen_to_auth_events(
295-
self, event: AuthChangeEvent, session: Union[Session, None]
293+
self, event: AuthChangeEvent, session: Optional[Session]
296294
):
297295
access_token = self.supabase_key
298296
if event in ["SIGNED_IN", "TOKEN_REFRESHED", "SIGNED_OUT"]:
@@ -308,7 +306,7 @@ def _listen_to_auth_events(
308306
def create_client(
309307
supabase_url: str,
310308
supabase_key: str,
311-
options: Union[ClientOptions, None] = None,
309+
options: Optional[ClientOptions] = None,
312310
) -> SyncClient:
313311
"""Create client function to instantiate supabase client like JS runtime.
314312

0 commit comments

Comments
 (0)