Skip to content

Commit 00585b3

Browse files
committed
Simplified GFG by removing some unneeded elses
1 parent d643a66 commit 00585b3

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

https_everywhere/_rules.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,15 @@ def _is_rule_only_force_https(ruleset, rule):
238238
)
239239
)
240240
return False
241-
else:
242-
# There are five of these, and the pattern and replacement have the same path, so can easily be
243-
# reduced by adding an exclusion as inverse regex of the path in the rule
244-
logger.info(
245-
"{} matches {} but has a path, and is not reducible yet".format(
246-
targets, rule.pattern
247-
)
241+
242+
# There are five of these, and the pattern and replacement have the same path, so can easily be
243+
# reduced by adding an exclusion as inverse regex of the path in the rule
244+
logger.info(
245+
"{} matches {} but has a path, and is not reducible yet".format(
246+
targets, rule.pattern
248247
)
249-
return False
248+
)
249+
return False
250250
else: # pragma: no cover
251251
logger.debug("{} not matches targets {}".format(rule.pattern, targets))
252252
assert rule.pattern_targets[0] in targets
@@ -444,7 +444,7 @@ def _reduce_ruleset(ruleset):
444444
# ~500 cases
445445
ruleset._rules = REMOVE_WWW_and_FORCE_HTTPS_RULES
446446
return True
447-
elif rule.add_www:
447+
if rule.add_www:
448448
# ~1100 cases
449449
ruleset._rules = ADD_WWW_and_FORCE_HTTPS_RULES
450450
return True

https_everywhere/_unregex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def expand_pattern(pattern, max_count=100):
6363
s, sorted(set(p.host) - valid_host_char)
6464
)
6565
)
66-
else:
67-
return [p.host]
66+
67+
return [p.host]
6868
except urllib3.exceptions.LocationParseError: # pragma: no cover
6969
# TODO: build test case for this
7070
pass
@@ -130,11 +130,11 @@ def split_regex(pattern, at, remainer=False):
130130
found = True
131131
del pattern[i]
132132
continue
133-
elif not found and tok == sre_parse.IN and (sre_parse.LITERAL, ord(at)) in val:
133+
if not found and tok == sre_parse.IN and (sre_parse.LITERAL, ord(at)) in val:
134134
found = True
135135
del pattern[i]
136136
continue
137-
elif not found and tok == sre_parse.MAX_REPEAT:
137+
if not found and tok == sre_parse.MAX_REPEAT:
138138
val = val[2]
139139
if (sre_parse.LITERAL, ord(at)) in val:
140140
found = True

https_everywhere/_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ def _reverse_host(host, trailing_dot=True):
55
rv = ".".join(reversed(host.split(".")))
66
if trailing_dot:
77
return rv + "."
8-
else:
9-
return rv
8+
9+
return rv
1010

1111

1212
def _check_in(domains, hostname):

https_everywhere/adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def _follow_redirects_on_http(self, url):
254254
if self._prevent_https(tail):
255255
return "http://" + tail
256256
return response
257-
elif location.startswith("http://"):
257+
if location.startswith("http://"):
258258
previous_url = current_url
259259
url = location
260260
else:
@@ -285,7 +285,7 @@ def send(self, request, *args, **kwargs):
285285
"upgrading {} to https with {}".format(url, redirect.url)
286286
)
287287
return redirect
288-
elif redirect != url:
288+
if redirect != url:
289289
if redirect.startswith("http://"):
290290
tail = url[7:]
291291
else:

0 commit comments

Comments
 (0)