mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-11-03 13:42:16 +08:00
Fix typing errors
This commit is contained in:
@ -93,7 +93,7 @@ class OrmarUserDatabase(BaseUserDatabase[UD]):
|
||||
self, model: OrmarBaseUserModel, oauth_accounts: List[BaseOAuthAccount]
|
||||
):
|
||||
if self.oauth_account_model:
|
||||
oauth_accounts_db: List[ormar.Model] = [
|
||||
oauth_accounts_db = [
|
||||
self.oauth_account_model(user=model, **oacc.dict())
|
||||
for oacc in oauth_accounts
|
||||
]
|
||||
|
||||
@ -168,21 +168,23 @@ class SQLAlchemyUserDatabase(BaseUserDatabase[UD]):
|
||||
if self.oauth_accounts is None:
|
||||
raise NotSetOAuthAccountTableError()
|
||||
|
||||
query = self.oauth_accounts.delete().where(
|
||||
delete_query = self.oauth_accounts.delete().where(
|
||||
self.oauth_accounts.c.user_id == user.id
|
||||
)
|
||||
await self.database.execute(query)
|
||||
await self.database.execute(delete_query)
|
||||
|
||||
oauth_accounts_values = []
|
||||
oauth_accounts = user_dict.pop("oauth_accounts")
|
||||
for oauth_account in oauth_accounts:
|
||||
oauth_accounts_values.append({"user_id": user.id, **oauth_account})
|
||||
|
||||
query = self.oauth_accounts.insert()
|
||||
await self.database.execute_many(query, oauth_accounts_values)
|
||||
insert_query = self.oauth_accounts.insert()
|
||||
await self.database.execute_many(insert_query, oauth_accounts_values)
|
||||
|
||||
query = self.users.update().where(self.users.c.id == user.id).values(user_dict)
|
||||
await self.database.execute(query)
|
||||
update_query = (
|
||||
self.users.update().where(self.users.c.id == user.id).values(user_dict)
|
||||
)
|
||||
await self.database.execute(update_query)
|
||||
return user
|
||||
|
||||
async def delete(self, user: UD) -> None:
|
||||
|
||||
@ -27,7 +27,7 @@ try:
|
||||
|
||||
from fastapi_users.router import get_oauth_router
|
||||
except ModuleNotFoundError: # pragma: no cover
|
||||
BaseOAuth2 = Type
|
||||
BaseOAuth2 = Type # type: ignore
|
||||
|
||||
|
||||
class FastAPIUsers:
|
||||
|
||||
@ -24,3 +24,4 @@ httpx-oauth
|
||||
httpx
|
||||
asgi_lifespan
|
||||
uvicorn
|
||||
sqlalchemy-stubs
|
||||
|
||||
Reference in New Issue
Block a user