Skip to content

Commit b74b04a

Browse files
committed
fix(socialaccount): revert typing imports conflicting startup
1 parent c493977 commit b74b04a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

allauth/socialaccount/providers/base/provider.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
from typing import Any, Dict, List, Optional
1+
from typing import Any, Dict, Optional
22

33
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
44
from django.http import HttpResponse
55

6-
from allauth.account.models import EmailAddress
76
from allauth.account.utils import get_next_redirect_url, get_request_param
87
from allauth.core import context
98
from allauth.socialaccount import app_settings
109
from allauth.socialaccount.adapter import get_adapter
1110
from allauth.socialaccount.internal import statekit
12-
from allauth.socialaccount.models import SocialLogin
1311
from allauth.socialaccount.providers.base.constants import AuthProcess
1412

1513

@@ -68,7 +66,7 @@ def redirect(
6866
"""
6967
raise NotImplementedError()
7068

71-
def verify_token(self, request, token) -> SocialLogin:
69+
def verify_token(self, request, token):
7270
"""
7371
Verifies the token, returning a `SocialLogin` instance when valid.
7472
Raises a `ValidationError` otherwise.
@@ -87,7 +85,7 @@ def wrap_account(self, social_account):
8785
def get_settings(self) -> dict:
8886
return app_settings.PROVIDERS.get(self.id, {})
8987

90-
def sociallogin_from_response(self, request, response) -> SocialLogin:
88+
def sociallogin_from_response(self, request, response):
9189
"""
9290
Instantiates and populates a `SocialLogin` model based on the data
9391
retrieved in `response`. The method does NOT save the model to the
@@ -178,6 +176,9 @@ def extract_common_fields(self, data) -> dict:
178176
def cleanup_email_addresses(
179177
self, email: Optional[str], addresses: list, email_verified: bool = False
180178
) -> Optional[str]:
179+
# Avoid loading models before adapters have been registered.
180+
from allauth.account.models import EmailAddress
181+
181182
# Move user.email over to EmailAddress
182183
if email and email.lower() not in [a.email.lower() for a in addresses]:
183184
addresses.insert(
@@ -196,7 +197,7 @@ def cleanup_email_addresses(
196197
email = addresses[0].email
197198
return email
198199

199-
def extract_email_addresses(self, data) -> List[EmailAddress]:
200+
def extract_email_addresses(self, data):
200201
"""
201202
For example:
202203

0 commit comments

Comments
 (0)