Skip to content

Commit e2add16

Browse files
committed
[py]: Apply black on the rest of the code base
1 parent 6b4281b commit e2add16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1597
-1460
lines changed

py/selenium/webdriver/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from .wpewebkit.options import Options as WPEWebKitOptions # noqa
3737
from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa
3838

39-
__version__ = '4.5.0'
39+
__version__ = "4.5.0"
4040

4141
# We need an explicit __all__ because the above won't otherwise be exported.
4242
__all__ = [

py/selenium/webdriver/chrome/options.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323

2424
class Options(ChromiumOptions):
25-
2625
@property
2726
def default_capabilities(self) -> dict:
2827
return DesiredCapabilities.CHROME.copy()
2928

30-
def enable_mobile(self,
31-
android_package: str = "com.android.chrome",
32-
android_activity: Optional[str] = None,
33-
device_serial: Optional[str] = None
34-
) -> None:
29+
def enable_mobile(
30+
self,
31+
android_package: str = "com.android.chrome",
32+
android_activity: Optional[str] = None,
33+
device_serial: Optional[str] = None,
34+
) -> None:
3535
super().enable_mobile(android_package, android_activity, device_serial)

py/selenium/webdriver/chrome/service.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ class Service(service.ChromiumService):
2727
Object that manages the starting and stopping of the ChromeDriver
2828
"""
2929

30-
def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH,
31-
port: int = 0, service_args: List[str] = None,
32-
log_path: str = None, env: dict = None):
30+
def __init__(
31+
self,
32+
executable_path: str = DEFAULT_EXECUTABLE_PATH,
33+
port: int = 0,
34+
service_args: List[str] = None,
35+
log_path: str = None,
36+
env: dict = None,
37+
):
3338
"""
3439
Creates a new instance of the Service
3540
@@ -40,9 +45,5 @@ def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH,
4045
- log_path : Path for the chromedriver service to log to"""
4146

4247
super().__init__(
43-
executable_path,
44-
port,
45-
service_args,
46-
log_path,
47-
env,
48-
"Please see https://chromedriver.chromium.org/home")
48+
executable_path, port, service_args, log_path, env, "Please see https://chromedriver.chromium.org/home"
49+
)

py/selenium/webdriver/chrome/webdriver.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ class WebDriver(ChromiumDriver):
3535
http://chromedriver.storage.googleapis.com/index.html
3636
"""
3737

38-
def __init__(self, executable_path=DEFAULT_EXECUTABLE_PATH, port=DEFAULT_PORT,
39-
options: Options = None, service_args=None,
40-
desired_capabilities=None, service_log_path=DEFAULT_SERVICE_LOG_PATH,
41-
chrome_options=None, service: Service = None, keep_alive=DEFAULT_KEEP_ALIVE):
38+
def __init__(
39+
self,
40+
executable_path=DEFAULT_EXECUTABLE_PATH,
41+
port=DEFAULT_PORT,
42+
options: Options = None,
43+
service_args=None,
44+
desired_capabilities=None,
45+
service_log_path=DEFAULT_SERVICE_LOG_PATH,
46+
chrome_options=None,
47+
service: Service = None,
48+
keep_alive=DEFAULT_KEEP_ALIVE,
49+
):
4250
"""
4351
Creates a new instance of the chrome driver.
4452
Starts the service and then creates new instance of chrome driver.
@@ -54,22 +62,30 @@ def __init__(self, executable_path=DEFAULT_EXECUTABLE_PATH, port=DEFAULT_PORT,
5462
- service_log_path - Deprecated: Where to log information from the driver.
5563
- keep_alive - Deprecated: Whether to configure ChromeRemoteConnection to use HTTP keep-alive.
5664
"""
57-
if executable_path != 'chromedriver':
58-
warnings.warn('executable_path has been deprecated, please pass in a Service object',
59-
DeprecationWarning, stacklevel=2)
65+
if executable_path != "chromedriver":
66+
warnings.warn(
67+
"executable_path has been deprecated, please pass in a Service object", DeprecationWarning, stacklevel=2
68+
)
6069
if chrome_options:
61-
warnings.warn('use options instead of chrome_options',
62-
DeprecationWarning, stacklevel=2)
70+
warnings.warn("use options instead of chrome_options", DeprecationWarning, stacklevel=2)
6371
options = chrome_options
6472
if keep_alive != DEFAULT_KEEP_ALIVE:
65-
warnings.warn('keep_alive has been deprecated, please pass in a Service object',
66-
DeprecationWarning, stacklevel=2)
73+
warnings.warn(
74+
"keep_alive has been deprecated, please pass in a Service object", DeprecationWarning, stacklevel=2
75+
)
6776
else:
6877
keep_alive = True
6978
if not service:
7079
service = Service(executable_path, port, service_args, service_log_path)
7180

72-
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
73-
port, options,
74-
service_args, desired_capabilities,
75-
service_log_path, service, keep_alive)
81+
super().__init__(
82+
DesiredCapabilities.CHROME["browserName"],
83+
"goog",
84+
port,
85+
options,
86+
service_args,
87+
desired_capabilities,
88+
service_log_path,
89+
service,
90+
keep_alive,
91+
)

py/selenium/webdriver/chromium/options.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ChromiumOptions(ArgOptions):
3131

3232
def __init__(self) -> None:
3333
super().__init__()
34-
self._binary_location = ''
34+
self._binary_location = ""
3535
self._extension_files = []
3636
self._extensions = []
3737
self._experimental_options = {}
@@ -76,6 +76,7 @@ def extensions(self) -> List[str]:
7676
"""
7777
:Returns: A list of encoded extensions that will be loaded
7878
"""
79+
7980
def _decode(file_data: BinaryIO) -> str:
8081
# Should not use base64.encodestring() which inserts newlines every
8182
# 76 characters (per RFC 1521). Chromedriver has to remove those
@@ -143,7 +144,7 @@ def headless(self) -> bool:
143144
"""
144145
:Returns: True if the headless argument is set, else False
145146
"""
146-
return '--headless' in self._arguments
147+
return "--headless" in self._arguments
147148

148149
@headless.setter
149150
def headless(self, value: bool) -> None:
@@ -152,7 +153,7 @@ def headless(self, value: bool) -> None:
152153
:Args:
153154
value: boolean value indicating to set the headless option
154155
"""
155-
args = {'--headless'}
156+
args = {"--headless"}
156157
if value is True:
157158
self._arguments.extend(args)
158159
else:
@@ -165,17 +166,17 @@ def to_capabilities(self) -> dict:
165166
"""
166167
caps = self._caps
167168
chrome_options = self.experimental_options.copy()
168-
if 'w3c' in chrome_options:
169-
if chrome_options['w3c']:
169+
if "w3c" in chrome_options:
170+
if chrome_options["w3c"]:
170171
warnings.warn(
171-
"Setting 'w3c: True' is redundant and will no longer be allowed",
172-
DeprecationWarning,
173-
stacklevel=2
172+
"Setting 'w3c: True' is redundant and will no longer be allowed", DeprecationWarning, stacklevel=2
174173
)
175174
else:
176-
raise AttributeError('setting w3c to False is not allowed, '
177-
'Please update to W3C Syntax: '
178-
'https://www.selenium.dev/blog/2022/legacy-protocol-support/')
175+
raise AttributeError(
176+
"setting w3c to False is not allowed, "
177+
"Please update to W3C Syntax: "
178+
"https://www.selenium.dev/blog/2022/legacy-protocol-support/"
179+
)
179180
if self.mobile_options:
180181
chrome_options.update(self.mobile_options)
181182
chrome_options["extensions"] = self.extensions

py/selenium/webdriver/chromium/remote_connection.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,28 @@
2020

2121

2222
class ChromiumRemoteConnection(RemoteConnection):
23-
def __init__(self,
24-
remote_server_addr: str,
25-
vendor_prefix: str,
26-
browser_name: str,
27-
keep_alive: bool = True,
28-
ignore_proxy: typing.Optional[bool] = False):
23+
def __init__(
24+
self,
25+
remote_server_addr: str,
26+
vendor_prefix: str,
27+
browser_name: str,
28+
keep_alive: bool = True,
29+
ignore_proxy: typing.Optional[bool] = False,
30+
):
2931
super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
3032
self.browser_name = browser_name
31-
self._commands["launchApp"] = ('POST', '/session/$sessionId/chromium/launch_app')
32-
self._commands["setPermissions"] = ('POST', '/session/$sessionId/permissions')
33-
self._commands["setNetworkConditions"] = ('POST', '/session/$sessionId/chromium/network_conditions')
34-
self._commands["getNetworkConditions"] = ('GET', '/session/$sessionId/chromium/network_conditions')
35-
self._commands["deleteNetworkConditions"] = ('DELETE', '/session/$sessionId/chromium/network_conditions')
36-
self._commands['executeCdpCommand'] = ('POST', f'/session/$sessionId/{vendor_prefix}/cdp/execute')
37-
self._commands['getSinks'] = ('GET', f'/session/$sessionId/{vendor_prefix}/cast/get_sinks')
38-
self._commands['getIssueMessage'] = ('GET', f'/session/$sessionId/{vendor_prefix}/cast/get_issue_message')
39-
self._commands['setSinkToUse'] = ('POST', f'/session/$sessionId/{vendor_prefix}/cast/set_sink_to_use')
40-
self._commands['startDesktopMirroring'] = ('POST', f'/session/$sessionId/{vendor_prefix}/cast/start_desktop_mirroring')
41-
self._commands['startTabMirroring'] = ('POST', f'/session/$sessionId/{vendor_prefix}/cast/start_tab_mirroring')
42-
self._commands['stopCasting'] = ('POST', f'/session/$sessionId/{vendor_prefix}/cast/stop_casting')
33+
self._commands["launchApp"] = ("POST", "/session/$sessionId/chromium/launch_app")
34+
self._commands["setPermissions"] = ("POST", "/session/$sessionId/permissions")
35+
self._commands["setNetworkConditions"] = ("POST", "/session/$sessionId/chromium/network_conditions")
36+
self._commands["getNetworkConditions"] = ("GET", "/session/$sessionId/chromium/network_conditions")
37+
self._commands["deleteNetworkConditions"] = ("DELETE", "/session/$sessionId/chromium/network_conditions")
38+
self._commands["executeCdpCommand"] = ("POST", f"/session/$sessionId/{vendor_prefix}/cdp/execute")
39+
self._commands["getSinks"] = ("GET", f"/session/$sessionId/{vendor_prefix}/cast/get_sinks")
40+
self._commands["getIssueMessage"] = ("GET", f"/session/$sessionId/{vendor_prefix}/cast/get_issue_message")
41+
self._commands["setSinkToUse"] = ("POST", f"/session/$sessionId/{vendor_prefix}/cast/set_sink_to_use")
42+
self._commands["startDesktopMirroring"] = (
43+
"POST",
44+
f"/session/$sessionId/{vendor_prefix}/cast/start_desktop_mirroring",
45+
)
46+
self._commands["startTabMirroring"] = ("POST", f"/session/$sessionId/{vendor_prefix}/cast/start_tab_mirroring")
47+
self._commands["stopCasting"] = ("POST", f"/session/$sessionId/{vendor_prefix}/cast/stop_casting")

py/selenium/webdriver/chromium/service.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,15 @@ class ChromiumService(service.Service):
2525
Object that manages the starting and stopping the WebDriver instance of the ChromiumDriver
2626
"""
2727

28-
def __init__(self, executable_path: str, port: int = 0, service_args: List[str] = None,
29-
log_path: str = None, env: dict = None, start_error_message: str = None):
28+
def __init__(
29+
self,
30+
executable_path: str,
31+
port: int = 0,
32+
service_args: List[str] = None,
33+
log_path: str = None,
34+
env: dict = None,
35+
start_error_message: str = None,
36+
):
3037
"""
3138
Creates a new instance of the Service
3239
@@ -38,7 +45,7 @@ def __init__(self, executable_path: str, port: int = 0, service_args: List[str]
3845

3946
self.service_args = service_args or []
4047
if log_path:
41-
self.service_args.append('--log-path=%s' % log_path)
48+
self.service_args.append("--log-path=%s" % log_path)
4249

4350
if not start_error_message:
4451
raise AttributeError("start_error_message should not be empty")

0 commit comments

Comments
 (0)