@@ -673,19 +673,20 @@ async def get_user(self, jwt: Optional[str] = None) -> Optional[UserResponse]:
673673 return parse_user_response (await self ._request ("GET" , "user" , jwt = jwt ))
674674
675675 async def update_user (
676- self , attributes : UserAttributes , options : UpdateUserOptions = {}
676+ self , attributes : UserAttributes , options : Optional [ UpdateUserOptions ]
677677 ) -> UserResponse :
678678 """
679679 Updates user data, if there is a logged in user.
680680 """
681681 session = await self .get_session ()
682682 if not session :
683683 raise AuthSessionMissingError ()
684+ update_options = options or {}
684685 response = await self ._request (
685686 "PUT" ,
686687 "user" ,
687688 body = attributes ,
688- redirect_to = options .get ("email_redirect_to" ),
689+ redirect_to = update_options .get ("email_redirect_to" ),
689690 jwt = session .access_token ,
690691 )
691692 user_response = parse_user_response (response )
@@ -761,7 +762,7 @@ async def refresh_session(
761762 session = await self ._call_refresh_token (refresh_token )
762763 return AuthResponse (session = session , user = session .user )
763764
764- async def sign_out (self , options : SignOutOptions = { "scope" : "global" } ) -> None :
765+ async def sign_out (self , options : Optional [ SignOutOptions ] = None ) -> None :
765766 """
766767 `sign_out` will remove the logged in user from the
767768 current session and log them out - removing all items from storage and then trigger a `"SIGNED_OUT"` event.
@@ -771,13 +772,14 @@ async def sign_out(self, options: SignOutOptions = {"scope": "global"}) -> None:
771772 There is no way to revoke a user's access token jwt until it expires.
772773 It is recommended to set a shorter expiry on the jwt for this reason.
773774 """
775+ signout_options = options or {"scope" : "global" }
774776 with suppress (AuthApiError ):
775777 session = await self .get_session ()
776778 access_token = session .access_token if session else None
777779 if access_token :
778- await self .admin .sign_out (access_token , options ["scope" ])
780+ await self .admin .sign_out (access_token , signout_options ["scope" ])
779781
780- if options ["scope" ] != "others" :
782+ if signout_options ["scope" ] != "others" :
781783 await self ._remove_session ()
782784 self ._notify_all_subscribers ("SIGNED_OUT" , None )
783785
@@ -801,31 +803,35 @@ def _unsubscribe() -> None:
801803 self ._state_change_emitters [unique_id ] = subscription
802804 return subscription
803805
804- async def reset_password_for_email (self , email : str , options : Options = {}) -> None :
806+ async def reset_password_for_email (
807+ self , email : str , options : Optional [Options ] = None
808+ ) -> None :
805809 """
806810 Sends a password reset request to an email address.
807811 """
812+ reset_options = options or {}
808813 await self ._request (
809814 "POST" ,
810815 "recover" ,
811816 body = {
812817 "email" : email ,
813818 "gotrue_meta_security" : {
814- "captcha_token" : options .get ("captcha_token" ),
819+ "captcha_token" : reset_options .get ("captcha_token" ),
815820 },
816821 },
817- redirect_to = options .get ("redirect_to" ),
822+ redirect_to = reset_options .get ("redirect_to" ),
818823 )
819824
820825 async def reset_password_email (
821826 self ,
822827 email : str ,
823- options : Options = {} ,
828+ options : Optional [ Options ] = None ,
824829 ) -> None :
825830 """
826831 Sends a password reset request to an email address.
827832 """
828- await self .reset_password_for_email (email , options )
833+
834+ await self .reset_password_for_email (email , options or {})
829835
830836 # MFA methods
831837
0 commit comments