Skip to content

Commit

Permalink
feat(account/adapter): Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Sep 21, 2024
1 parent d04109a commit 0aaf088
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions allauth/account/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ def is_email_verified(self, request, email):
ret = verified_email.lower() == email.lower()
return ret

def can_delete_email(self, email_address):
def can_delete_email(self, email_address) -> bool:
"""
Returns whether or not the given email address can be deleted.
"""
from allauth.account.models import EmailAddress

has_other = (
Expand Down Expand Up @@ -131,7 +134,10 @@ def can_delete_email(self, email_address):
else:
return True

def format_email_subject(self, subject):
def format_email_subject(self, subject) -> str:
"""
Formats the given email subject.
"""
prefix = app_settings.EMAIL_SUBJECT_PREFIX
if prefix is None:
site = get_current_site(context.request)
Expand Down Expand Up @@ -523,7 +529,10 @@ def confirm_email(self, request, email_address):

return email_verification.verify_email(request, email_address)

def set_password(self, user, password):
def set_password(self, user, password) -> None:
"""
Sets the password for the user.
"""
user.set_password(password)
user.save()

Expand Down Expand Up @@ -779,9 +788,15 @@ def send_notification_mail(self, template_prefix, user, context=None, email=None
self.send_mail(template_prefix, email, ctx)

def generate_login_code(self) -> str:
"""
Generates a new login code.
"""
return self._generate_code()

def generate_email_verification_code(self) -> str:
"""
Generates a new email verification code.
"""
return self._generate_code()

def _generate_code(self):
Expand Down

0 comments on commit 0aaf088

Please sign in to comment.