Skip to content

Commit c24ca17

Browse files
committed
[py]: remove alot of redundant else clauses throughout
1 parent 96eaad4 commit c24ca17

6 files changed

Lines changed: 8 additions & 19 deletions

File tree

py/selenium/webdriver/chromium/webdriver.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,4 @@ def quit(self) -> None:
238238
self.service.stop()
239239

240240
def create_options(self) -> BaseOptions:
241-
if self.vendor_prefix == "ms":
242-
return EdgeOptions()
243-
else:
244-
return ChromeOptions()
241+
return EdgeOptions() if self.vendor_prefix == "ms" else ChromeOptions()

py/selenium/webdriver/common/service.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def send_remote_shutdown_command(self):
126126
for x in range(30):
127127
if not self.is_connectable():
128128
break
129-
else:
130-
sleep(1)
129+
sleep(1)
131130

132131
def stop(self):
133132
"""

py/selenium/webdriver/common/timeouts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ def script(self, _script: float) -> None:
9999
def _convert(self, timeout: float) -> int:
100100
if isinstance(timeout, (int, float)):
101101
return int(float(timeout) * 1000)
102-
else:
103-
raise TypeError("Timeouts can only be an int or a float")
102+
raise TypeError("Timeouts can only be an int or a float")
104103

105104
def _to_json(self) -> JSONTimeouts:
106105
timeouts: JSONTimeouts = {}

py/selenium/webdriver/common/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,7 @@ def is_url_connectable(port: Union[int, str]) -> bool:
126126

127127
try:
128128
res = url_request.urlopen("http://127.0.0.1:%s/status" % port)
129-
if res.getcode() == 200:
130-
return True
131-
else:
132-
return False
129+
return res.getcode() == 200
133130
except Exception:
134131
return False
135132

py/selenium/webdriver/remote/remote_connection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,8 @@ def _request(self, method, url, body=None):
402402
if 'value' not in data:
403403
data['value'] = None
404404
return data
405-
else:
406-
data = {'status': 0, 'value': data}
407-
return data
405+
data = {'status': 0, 'value': data}
406+
return data
408407
finally:
409408
LOGGER.debug("Finished Request")
410409
response.close()

py/selenium/webdriver/remote/webdriver.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ def __init__(self, command_executor='http://127.0.0.1:4444',
253253
if desired_capabilities:
254254
if not isinstance(desired_capabilities, dict):
255255
raise WebDriverException("Desired Capabilities must be a dictionary")
256-
else:
257-
capabilities.update(desired_capabilities)
256+
capabilities.update(desired_capabilities)
258257
self.command_executor = command_executor
259258
if isinstance(self.command_executor, (str, bytes)):
260259
self.command_executor = get_remote_connection(capabilities, command_executor=command_executor,
@@ -329,8 +328,7 @@ def name(self) -> str:
329328
"""
330329
if 'browserName' in self.caps:
331330
return self.caps['browserName']
332-
else:
333-
raise KeyError('browserName not specified in session capabilities')
331+
raise KeyError('browserName not specified in session capabilities')
334332

335333
def start_client(self):
336334
"""

0 commit comments

Comments
 (0)