11"""FastAPI Users database adapter for SQLAlchemy."""
2+
23import uuid
3- from typing import TYPE_CHECKING , Any , Dict , Generic , Optional , Type
4+ from typing import TYPE_CHECKING , Any , Generic , Optional
45
56from fastapi_users .db .base import BaseUserDatabase
67from fastapi_users .models import ID , OAP , UP
@@ -103,14 +104,14 @@ class SQLAlchemyUserDatabase(Generic[UP, ID], BaseUserDatabase[UP, ID]):
103104 """
104105
105106 session : AsyncSession
106- user_table : Type [UP ]
107- oauth_account_table : Optional [Type [SQLAlchemyBaseOAuthAccountTable ]]
107+ user_table : type [UP ]
108+ oauth_account_table : Optional [type [SQLAlchemyBaseOAuthAccountTable ]]
108109
109110 def __init__ (
110111 self ,
111112 session : AsyncSession ,
112- user_table : Type [UP ],
113- oauth_account_table : Optional [Type [SQLAlchemyBaseOAuthAccountTable ]] = None ,
113+ user_table : type [UP ],
114+ oauth_account_table : Optional [type [SQLAlchemyBaseOAuthAccountTable ]] = None ,
114115 ):
115116 self .session = session
116117 self .user_table = user_table
@@ -138,14 +139,14 @@ async def get_by_oauth_account(self, oauth: str, account_id: str) -> Optional[UP
138139 )
139140 return await self ._get_user (statement )
140141
141- async def create (self , create_dict : Dict [str , Any ]) -> UP :
142+ async def create (self , create_dict : dict [str , Any ]) -> UP :
142143 user = self .user_table (** create_dict )
143144 self .session .add (user )
144145 await self .session .commit ()
145146 await self .session .refresh (user )
146147 return user
147148
148- async def update (self , user : UP , update_dict : Dict [str , Any ]) -> UP :
149+ async def update (self , user : UP , update_dict : dict [str , Any ]) -> UP :
149150 for key , value in update_dict .items ():
150151 setattr (user , key , value )
151152 self .session .add (user )
@@ -157,7 +158,7 @@ async def delete(self, user: UP) -> None:
157158 await self .session .delete (user )
158159 await self .session .commit ()
159160
160- async def add_oauth_account (self , user : UP , create_dict : Dict [str , Any ]) -> UP :
161+ async def add_oauth_account (self , user : UP , create_dict : dict [str , Any ]) -> UP :
161162 if self .oauth_account_table is None :
162163 raise NotImplementedError ()
163164
@@ -172,7 +173,7 @@ async def add_oauth_account(self, user: UP, create_dict: Dict[str, Any]) -> UP:
172173 return user
173174
174175 async def update_oauth_account (
175- self , user : UP , oauth_account : OAP , update_dict : Dict [str , Any ]
176+ self , user : UP , oauth_account : OAP , update_dict : dict [str , Any ]
176177 ) -> UP :
177178 if self .oauth_account_table is None :
178179 raise NotImplementedError ()
0 commit comments