Skip to content

Commit 40c16bb

Browse files
authored
[py]: Enable co-operative multi inheritance with super() throughout (#10773)
* [py]: Enable multi co-operative inheritance with `super()` throughout * [py]: Fix `_URL` param in firefox extension and indentation
1 parent 1b1058a commit 40c16bb

File tree

16 files changed

+23
-33
lines changed

16 files changed

+23
-33
lines changed

py/selenium/webdriver/chromium/remote_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class ChromiumRemoteConnection(RemoteConnection):
2222
def __init__(self, remote_server_addr, vendor_prefix, browser_name, keep_alive=True, ignore_proxy=False):
23-
RemoteConnection.__init__(self, remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
23+
super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
2424
self.browser_name = browser_name
2525
self._commands["launchApp"] = ('POST', '/session/$sessionId/chromium/launch_app')
2626
self._commands["setPermissions"] = ('POST', '/session/$sessionId/permissions')

py/selenium/webdriver/chromium/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, executable_path: str, port: int = 0, service_args: List[str]
4242
if not start_error_message:
4343
raise AttributeError("start_error_message should not be empty")
4444

45-
service.Service.__init__(self, executable_path, port=port, env=env, start_error_message=start_error_message)
45+
super().__init__(executable_path, port=port, env=env, start_error_message=start_error_message)
4646

4747
def command_line_args(self) -> List[str]:
4848
return ["--port=%d" % self.port] + self.service_args

py/selenium/webdriver/chromium/webdriver.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ def __init__(self, browser_name, vendor_prefix,
8989
self.service.start()
9090

9191
try:
92-
RemoteWebDriver.__init__(
93-
self,
92+
super().__init__(
9493
command_executor=ChromiumRemoteConnection(
9594
remote_server_addr=self.service.service_url,
9695
browser_name=browser_name, vendor_prefix=vendor_prefix,
@@ -231,7 +230,7 @@ def quit(self) -> None:
231230
that is started when starting the ChromiumDriver
232231
"""
233232
try:
234-
RemoteWebDriver.quit(self)
233+
super().quit()
235234
except Exception:
236235
# We don't care about the message because something probably has gone wrong
237236
pass

py/selenium/webdriver/firefox/extension_connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def __init__(self, host, firefox_profile, firefox_binary=None, timeout=30):
5151

5252
self.binary.launch_browser(self.profile, timeout=timeout)
5353
_URL = "http://%s:%d/hub" % (HOST, PORT)
54-
RemoteConnection.__init__(
55-
self, _URL, keep_alive=True)
54+
super().__init__(_URL, keep_alive=True)
5655

5756
def quit(self, sessionId=None):
5857
self.execute(Command.QUIT, {'sessionId': sessionId})

py/selenium/webdriver/firefox/remote_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FirefoxRemoteConnection(RemoteConnection):
2424
browser_name = DesiredCapabilities.FIREFOX['browserName']
2525

2626
def __init__(self, remote_server_addr, keep_alive=True, ignore_proxy=False):
27-
RemoteConnection.__init__(self, remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
27+
super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
2828

2929
self._commands["GET_CONTEXT"] = ('GET', '/session/$sessionId/moz/context')
3030
self._commands["SET_CONTEXT"] = ("POST", "/session/$sessionId/moz/context")

py/selenium/webdriver/firefox/service.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH,
4848
"""
4949
log_file = open(log_path, "a+") if log_path else None
5050

51-
service.Service.__init__(
52-
self, executable_path, port=port, log_file=log_file, env=env)
51+
super().__init__(executable_path, port=port, log_file=log_file, env=env)
5352
self.service_args = service_args or []
5453

5554
# Set a port for CDP

py/selenium/webdriver/firefox/webdriver.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
174174
executor = FirefoxRemoteConnection(
175175
remote_server_addr=self.service.service_url,
176176
ignore_proxy=options._ignore_local_proxy)
177-
RemoteWebDriver.__init__(
178-
self,
177+
super().__init__(
179178
command_executor=executor,
180179
options=options,
181180
keep_alive=True)
@@ -185,7 +184,7 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
185184
def quit(self) -> None:
186185
"""Quits the driver and close every associated window."""
187186
try:
188-
RemoteWebDriver.quit(self)
187+
super().quit()
189188
except Exception:
190189
# We don't care about the message because something probably has gone wrong
191190
pass

py/selenium/webdriver/ie/service.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from selenium.webdriver.common import service
2121

22-
2322
DEFAULT_EXECUTABLE_PATH = 'IEDriverServer.exe'
2423

2524

@@ -50,8 +49,8 @@ def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH,
5049
if log_file:
5150
self.service_args.append("--log-file=%s" % log_file)
5251

53-
service.Service.__init__(self, executable_path, port=port,
54-
start_error_message="Please download from https://www.selenium.dev/downloads/ and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver")
52+
super().__init__(executable_path, port=port,
53+
start_error_message="Please download from https://www.selenium.dev/downloads/ and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver")
5554

5655
def command_line_args(self) -> List[str]:
5756
return ["--port=%d" % self.port] + self.service_args

py/selenium/webdriver/ie/webdriver.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,14 @@ def __init__(self, executable_path=DEFAULT_EXECUTABLE_PATH, capabilities=None,
107107

108108
self.iedriver.start()
109109

110-
RemoteWebDriver.__init__(
111-
self,
110+
super().__init__(
112111
command_executor=self.iedriver.service_url,
113112
options=options,
114113
keep_alive=keep_alive)
115114
self._is_remote = False
116115

117116
def quit(self) -> None:
118-
RemoteWebDriver.quit(self)
117+
super().quit()
119118
self.iedriver.stop()
120119

121120
def create_options(self) -> Options:

py/selenium/webdriver/safari/remote_connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class SafariRemoteConnection(RemoteConnection):
2424
browser_name = DesiredCapabilities.SAFARI['browserName']
2525

2626
def __init__(self, remote_server_addr, keep_alive=True, ignore_proxy=False):
27-
RemoteConnection.__init__(self, remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
28-
27+
super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
2928
self._commands["GET_PERMISSIONS"] = ('GET', '/session/$sessionId/apple/permissions')
3029
self._commands["SET_PERMISSIONS"] = ('POST', '/session/$sessionId/apple/permissions')
3130
self._commands["ATTACH_DEBUGGER"] = ('POST', '/session/$sessionId/apple/attach_debugger')

0 commit comments

Comments
 (0)