Skip to content

Commit f08c75f

Browse files
committed
chore: remove not needed else after return
1 parent e3332e8 commit f08c75f

File tree

13 files changed

+34
-51
lines changed

13 files changed

+34
-51
lines changed

social_core/backends/apple.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def get_apple_jwk(self, kid=None):
107107

108108
if kid:
109109
return json.dumps([key for key in keys if key["kid"] == kid][0])
110-
else:
111-
return (json.dumps(key) for key in keys)
110+
return (json.dumps(key) for key in keys)
112111

113112
def decode_id_token(self, id_token):
114113
"""

social_core/backends/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def setting(self, name, default=None):
3232
def start(self):
3333
if self.uses_redirect():
3434
return self.strategy.redirect(self.auth_url())
35-
else:
36-
return self.strategy.html(self.auth_html())
35+
return self.strategy.html(self.auth_html())
3736

3837
def complete(self, *args, **kwargs):
3938
return self.auth_complete(*args, **kwargs)

social_core/backends/google.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ def get_user_id(self, details, response):
1414
if self.setting("USE_UNIQUE_USER_ID", False):
1515
if "sub" in response:
1616
return response["sub"]
17-
else:
18-
return response["id"]
19-
else:
20-
return details["email"]
17+
return response["id"]
18+
return details["email"]
2119

2220
def get_user_details(self, response):
2321
"""Return user details from Google API account"""
@@ -115,7 +113,7 @@ def auth_complete(self, *args, **kwargs):
115113
)
116114
self.process_error(response)
117115
return self.do_auth(token, response=response, *args, **kwargs)
118-
elif "code" in self.data: # Server-side workflow
116+
if "code" in self.data: # Server-side workflow
119117
response = self.request_access_token(
120118
self.ACCESS_TOKEN_URL,
121119
data=self.auth_complete_params(),
@@ -126,11 +124,10 @@ def auth_complete(self, *args, **kwargs):
126124
return self.do_auth(
127125
response["access_token"], response=response, *args, **kwargs
128126
)
129-
elif "id_token" in self.data: # Client-side workflow
127+
if "id_token" in self.data: # Client-side workflow
130128
token = self.data.get("id_token")
131129
return self.do_auth(token, *args, **kwargs)
132-
else:
133-
raise AuthMissingParameter(self, "access_token, id_token, or code")
130+
raise AuthMissingParameter(self, "access_token, id_token, or code")
134131

135132
def user_data(self, access_token, *args, **kwargs):
136133
if "id_token" not in self.data:

social_core/backends/mediawiki.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def force_unicode(value):
2121
"""
2222
if isinstance(value, str):
2323
return value
24-
else:
25-
return str(value, "unicode-escape")
24+
return str(value, "unicode-escape")
2625

2726

2827
class MediaWiki(BaseOAuth1):

social_core/backends/open_id.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ def openid_url(self):
253253
provider URL."""
254254
if self.URL:
255255
return self.URL
256-
elif OPENID_ID_FIELD in self.data:
256+
if OPENID_ID_FIELD in self.data:
257257
return self.data[OPENID_ID_FIELD]
258-
else:
259-
raise AuthMissingParameter(self, OPENID_ID_FIELD)
258+
raise AuthMissingParameter(self, OPENID_ID_FIELD)

social_core/backends/qiita.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,4 @@ def get_user_id(self, details, response):
8383

8484
if user_id is not None:
8585
return str(user_id)
86-
else:
87-
raise AuthException("failed to get user id")
86+
raise AuthException("failed to get user id")

social_core/pipeline/social_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def associate_by_email(backend, details, user=None, *args, **kwargs):
7474
users = list(backend.strategy.storage.user.get_users_by_email(email))
7575
if len(users) == 0:
7676
return None
77-
elif len(users) > 1:
77+
if len(users) > 1:
7878
raise AuthException(
7979
backend, "The given email address is associated with another account"
8080
)

social_core/storage.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,14 @@ def expiration_timedelta(self):
7474
# expires is a datetime, return the remaining difference
7575
expiry_time = datetime.fromtimestamp(expires, tz=timezone.utc)
7676
return expiry_time - now
77-
else:
78-
# expires is the time to live seconds since creation,
79-
# check against auth_time if present, otherwise return
80-
# the value
81-
auth_time = self.extra_data.get("auth_time")
82-
if auth_time:
83-
reference = datetime.fromtimestamp(auth_time, tz=timezone.utc)
84-
return (reference + timedelta(seconds=expires)) - now
85-
else:
86-
return timedelta(seconds=expires)
77+
# expires is the time to live seconds since creation,
78+
# check against auth_time if present, otherwise return
79+
# the value
80+
auth_time = self.extra_data.get("auth_time")
81+
if auth_time:
82+
reference = datetime.fromtimestamp(auth_time, tz=timezone.utc)
83+
return (reference + timedelta(seconds=expires)) - now
84+
return timedelta(seconds=expires)
8785

8886
def expiration_datetime(self):
8987
# backward compatible alias

social_core/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def removeAssociation(self, server_url, handle):
3030
def expiresIn(self, assoc):
3131
if hasattr(assoc, "getExpiresIn"):
3232
return assoc.getExpiresIn()
33-
else: # python3-openid 3.0.2
34-
return assoc.expiresIn
33+
# python3-openid 3.0.2
34+
return assoc.expiresIn
3535

3636
def getAssociation(self, server_url, handle=None):
3737
"""Return stored association"""

social_core/strategy.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def render(self, tpl=None, html=None, context=None):
1919
context = context or {}
2020
if tpl:
2121
return self.render_template(tpl, context)
22-
else:
23-
return self.render_string(html, context)
22+
return self.render_string(html, context)
2423

2524
def render_template(self, tpl, context):
2625
raise NotImplementedError("Implement in subclass")
@@ -137,13 +136,12 @@ def validate_email(self, email, code):
137136
verification_code = self.storage.code.get_code(code)
138137
if not verification_code or verification_code.code != code:
139138
return False
140-
elif verification_code.email != email:
139+
if verification_code.email != email:
141140
return False
142-
elif verification_code.verified:
141+
if verification_code.verified:
143142
return False
144-
else:
145-
verification_code.verify()
146-
return True
143+
verification_code.verify()
144+
return True
147145

148146
def render_html(self, tpl=None, html=None, context=None):
149147
"""Render given template or raw html with given context"""

0 commit comments

Comments
 (0)