Skip to content

Commit 7217bb3

Browse files
[python] replace misuses of typing.NoReturn (#10462)
* replace incorrect uses of `typing.NoReturn` in `ChromiumOptions` * fix other misuses of `typing.NoReturn` Co-authored-by: David Burns <david.burns@theautomatedtester.co.uk>
1 parent a76e185 commit 7217bb3

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

‎py/selenium/webdriver/chromium/options.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import base64
1919
import os
2020
import warnings
21-
from typing import List, NoReturn, Union
21+
from typing import List, Union
2222

2323
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
2424
from selenium.webdriver.common.options import ArgOptions
@@ -43,7 +43,7 @@ def binary_location(self) -> str:
4343
return self._binary_location
4444

4545
@binary_location.setter
46-
def binary_location(self, value: str) -> NoReturn:
46+
def binary_location(self, value: str) -> None:
4747
"""
4848
Allows you to set where the chromium binary lives
4949
:Args:
@@ -59,7 +59,7 @@ def debugger_address(self: str) -> str:
5959
return self._debugger_address
6060

6161
@debugger_address.setter
62-
def debugger_address(self, value: str) -> NoReturn:
62+
def debugger_address(self, value: str) -> None:
6363
"""
6464
Allows you to set the address of the remote devtools instance
6565
that the ChromeDriver instance will try to connect to during an
@@ -85,7 +85,7 @@ def extensions(self) -> List[str]:
8585
file_.close()
8686
return encoded_extensions + self._extensions
8787

88-
def add_extension(self, extension: str) -> NoReturn:
88+
def add_extension(self, extension: str) -> None:
8989
"""
9090
Adds the path to the extension to a list that will be used to extract it
9191
to the ChromeDriver
@@ -102,7 +102,7 @@ def add_extension(self, extension: str) -> NoReturn:
102102
else:
103103
raise ValueError("argument can not be null")
104104

105-
def add_encoded_extension(self, extension: str) -> NoReturn:
105+
def add_encoded_extension(self, extension: str) -> None:
106106
"""
107107
Adds Base64 encoded string with extension data to a list that will be used to extract it
108108
to the ChromeDriver
@@ -122,7 +122,7 @@ def experimental_options(self) -> dict:
122122
"""
123123
return self._experimental_options
124124

125-
def add_experimental_option(self, name: str, value: Union[str, int, dict, List[str]]) -> NoReturn:
125+
def add_experimental_option(self, name: str, value: Union[str, int, dict, List[str]]) -> None:
126126
"""
127127
Adds an experimental option which is passed to chromium.
128128
@@ -142,7 +142,7 @@ def headless(self) -> bool:
142142
return '--headless' in self._arguments
143143

144144
@headless.setter
145-
def headless(self, value: bool) -> NoReturn:
145+
def headless(self, value: bool) -> None:
146146
"""
147147
Sets the headless argument
148148
:Args:

‎py/selenium/webdriver/chromium/webdriver.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import NoReturn
1918
from selenium.webdriver.common.options import BaseOptions
2019
from selenium.webdriver.common.service import Service
2120
from selenium.webdriver.edge.options import Options as EdgeOptions
@@ -117,7 +116,7 @@ def get_network_conditions(self):
117116
"""
118117
return self.execute("getNetworkConditions")['value']
119118

120-
def set_network_conditions(self, **network_conditions) -> NoReturn:
119+
def set_network_conditions(self, **network_conditions) -> None:
121120
"""
122121
Sets Chromium network emulation settings.
123122
@@ -139,13 +138,13 @@ def set_network_conditions(self, **network_conditions) -> NoReturn:
139138
'network_conditions': network_conditions
140139
})
141140

142-
def delete_network_conditions(self) -> NoReturn:
141+
def delete_network_conditions(self) -> None:
143142
"""
144143
Resets Chromium network emulation settings.
145144
"""
146145
self.execute("deleteNetworkConditions")
147146

148-
def set_permissions(self, name: str, value: str) -> NoReturn:
147+
def set_permissions(self, name: str, value: str) -> None:
149148
"""
150149
Sets Applicable Permission.
151150
@@ -226,7 +225,7 @@ def stop_casting(self, sink_name: str) -> str:
226225
"""
227226
return self.execute('stopCasting', {'sinkName': sink_name})
228227

229-
def quit(self) -> NoReturn:
228+
def quit(self) -> None:
230229
"""
231230
Closes the browser and shuts down the ChromiumDriver executable
232231
that is started when starting the ChromiumDriver

‎py/selenium/webdriver/firefox/webdriver.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from shutil import rmtree
2121
import warnings
2222
from contextlib import contextmanager
23-
from typing import NoReturn
2423
import zipfile
2524

2625
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
@@ -186,7 +185,7 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
186185

187186
self._is_remote = False
188187

189-
def quit(self) -> NoReturn:
188+
def quit(self) -> None:
190189
"""Quits the driver and close every associated window."""
191190
try:
192191
RemoteWebDriver.quit(self)
@@ -210,7 +209,7 @@ def firefox_profile(self):
210209

211210
# Extension commands:
212211

213-
def set_context(self, context) -> NoReturn:
212+
def set_context(self, context) -> None:
214213
self.execute("SET_CONTEXT", {"context": context})
215214

216215
@contextmanager
@@ -266,7 +265,7 @@ def install_addon(self, path, temporary=False) -> str:
266265
payload = {"addon": addon, "temporary": temporary}
267266
return self.execute("INSTALL_ADDON", payload)["value"]
268267

269-
def uninstall_addon(self, identifier) -> NoReturn:
268+
def uninstall_addon(self, identifier) -> None:
270269
"""
271270
Uninstalls Firefox addon using its identifier.
272271

‎py/selenium/webdriver/ie/webdriver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import NoReturn
1918
import warnings
2019

2120
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
@@ -115,7 +114,7 @@ def __init__(self, executable_path=DEFAULT_EXECUTABLE_PATH, capabilities=None,
115114
keep_alive=keep_alive)
116115
self._is_remote = False
117116

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

0 commit comments

Comments
 (0)