Skip to content

Commit e3332e8

Browse files
committed
chore: use startswith with tuple
This allows to join multiple lookups.
1 parent 90ebc0a commit e3332e8

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

social_core/tests/strategy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def session_pop(self, name):
8484
def build_absolute_uri(self, path=None):
8585
"""Build absolute URI with given (optional) path"""
8686
path = path or ""
87-
if path.startswith("http://") or path.startswith("https://"):
87+
if path.startswith(("http://", "https://")):
8888
return path
8989
return TEST_URI + path
9090

social_core/utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def partial_pipeline_data(backend, user=None, partial_token=None, *args, **kwarg
214214
def build_absolute_uri(host_url, path=None):
215215
"""Build absolute URI with given (optional) path"""
216216
path = path or ""
217-
if path.startswith("http://") or path.startswith("https://"):
217+
if path.startswith(("http://", "https://")):
218218
return path
219219
if host_url.endswith("/") and path.startswith("/"):
220220
path = path[1:]
@@ -231,11 +231,7 @@ def constant_time_compare(val1, val2):
231231

232232

233233
def is_url(value):
234-
return value and (
235-
value.startswith("http://")
236-
or value.startswith("https://")
237-
or value.startswith("/")
238-
)
234+
return value and (value.startswith(("http://", "https://", "/")))
239235

240236

241237
def setting_url(backend, *names):

0 commit comments

Comments
 (0)