diff --git a/supabase/_async/client.py b/supabase/_async/client.py index b0048354..666571f1 100644 --- a/supabase/_async/client.py +++ b/supabase/_async/client.py @@ -34,7 +34,7 @@ def __init__( self, supabase_url: str, supabase_key: str, - options: Union[ClientOptions, None] = None, + options: Optional[ClientOptions] = None, ): """Instantiate the client. @@ -97,7 +97,7 @@ async def create( cls, supabase_url: str, supabase_key: str, - options: Union[ClientOptions, None] = None, + options: Optional[ClientOptions] = None, ): auth_header = options.headers.get("Authorization") if options else None client = cls(supabase_url, supabase_key, options) @@ -278,9 +278,7 @@ def _init_postgrest_client( def _create_auth_header(self, token: str): return f"Bearer {token}" - def _get_auth_headers( - self, authorization: Union[str, None] = None - ) -> Dict[str, str]: + def _get_auth_headers(self, authorization: Optional[str] = None) -> Dict[str, str]: if authorization is None: authorization = self.options.headers.get( "Authorization", self._create_auth_header(self.supabase_key) @@ -293,7 +291,7 @@ def _get_auth_headers( } def _listen_to_auth_events( - self, event: AuthChangeEvent, session: Union[Session, None] + self, event: AuthChangeEvent, session: Optional[Session] ): access_token = self.supabase_key if event in ["SIGNED_IN", "TOKEN_REFRESHED", "SIGNED_OUT"]: @@ -310,7 +308,7 @@ def _listen_to_auth_events( async def create_client( supabase_url: str, supabase_key: str, - options: Union[ClientOptions, None] = None, + options: Optional[ClientOptions] = None, ) -> AsyncClient: """Create client function to instantiate supabase client like JS runtime. diff --git a/supabase/_sync/client.py b/supabase/_sync/client.py index 9eadb47b..f3ed2ba6 100644 --- a/supabase/_sync/client.py +++ b/supabase/_sync/client.py @@ -33,7 +33,7 @@ def __init__( self, supabase_url: str, supabase_key: str, - options: Union[ClientOptions, None] = None, + options: Optional[ClientOptions] = None, ): """Instantiate the client. @@ -96,7 +96,7 @@ def create( cls, supabase_url: str, supabase_key: str, - options: Union[ClientOptions, None] = None, + options: Optional[ClientOptions] = None, ): auth_header = options.headers.get("Authorization") if options else None client = cls(supabase_url, supabase_key, options) @@ -277,9 +277,7 @@ def _init_postgrest_client( def _create_auth_header(self, token: str): return f"Bearer {token}" - def _get_auth_headers( - self, authorization: Union[str, None] = None - ) -> Dict[str, str]: + def _get_auth_headers(self, authorization: Optional[str] = None) -> Dict[str, str]: if authorization is None: authorization = self.options.headers.get( "Authorization", self._create_auth_header(self.supabase_key) @@ -292,7 +290,7 @@ def _get_auth_headers( } def _listen_to_auth_events( - self, event: AuthChangeEvent, session: Union[Session, None] + self, event: AuthChangeEvent, session: Optional[Session] ): access_token = self.supabase_key if event in ["SIGNED_IN", "TOKEN_REFRESHED", "SIGNED_OUT"]: @@ -308,7 +306,7 @@ def _listen_to_auth_events( def create_client( supabase_url: str, supabase_key: str, - options: Union[ClientOptions, None] = None, + options: Optional[ClientOptions] = None, ) -> SyncClient: """Create client function to instantiate supabase client like JS runtime.