From 3152c96eb0f2e14fd5faa378a51282fc4f42a07c Mon Sep 17 00:00:00 2001 From: symonk Date: Sat, 10 Dec 2022 11:46:09 +0000 Subject: [PATCH] [py]: type hints for missing dunder `__init__` --- py/selenium/webdriver/chrome/webdriver.py | 2 +- py/selenium/webdriver/chromium/remote_connection.py | 2 +- py/selenium/webdriver/chromium/service.py | 2 +- py/selenium/webdriver/chromium/webdriver.py | 2 +- py/selenium/webdriver/edge/service.py | 2 +- py/selenium/webdriver/edge/webdriver.py | 4 ++-- py/selenium/webdriver/firefox/remote_connection.py | 2 +- py/selenium/webdriver/firefox/service.py | 2 +- py/selenium/webdriver/firefox/webdriver.py | 4 ++-- py/selenium/webdriver/ie/options.py | 2 +- py/selenium/webdriver/ie/service.py | 2 +- py/selenium/webdriver/ie/webdriver.py | 2 +- py/selenium/webdriver/remote/webdriver.py | 2 +- py/selenium/webdriver/remote/webelement.py | 4 ++-- py/selenium/webdriver/safari/remote_connection.py | 2 +- py/selenium/webdriver/safari/service.py | 2 +- py/selenium/webdriver/safari/webdriver.py | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/py/selenium/webdriver/chrome/webdriver.py b/py/selenium/webdriver/chrome/webdriver.py index 6c8aa904155c4..ffb13a11f71dd 100644 --- a/py/selenium/webdriver/chrome/webdriver.py +++ b/py/selenium/webdriver/chrome/webdriver.py @@ -46,7 +46,7 @@ def __init__( chrome_options=None, service: Service = None, keep_alive=DEFAULT_KEEP_ALIVE, - ): + ) -> None: """ Creates a new instance of the chrome driver. Starts the service and then creates new instance of chrome driver. diff --git a/py/selenium/webdriver/chromium/remote_connection.py b/py/selenium/webdriver/chromium/remote_connection.py index f3ca4b645c913..c2e7c9a614d46 100644 --- a/py/selenium/webdriver/chromium/remote_connection.py +++ b/py/selenium/webdriver/chromium/remote_connection.py @@ -27,7 +27,7 @@ def __init__( browser_name: str, keep_alive: bool = True, ignore_proxy: typing.Optional[bool] = False, - ): + ) -> None: super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy) self.browser_name = browser_name self._commands["launchApp"] = ("POST", "/session/$sessionId/chromium/launch_app") diff --git a/py/selenium/webdriver/chromium/service.py b/py/selenium/webdriver/chromium/service.py index 6e005ab114712..ef40286f7a495 100644 --- a/py/selenium/webdriver/chromium/service.py +++ b/py/selenium/webdriver/chromium/service.py @@ -40,7 +40,7 @@ def __init__( log_path: typing.Optional[str] = None, env: typing.Optional[typing.Mapping[str, str]] = None, start_error_message: typing.Optional[str] = None, - ): + ) -> None: self.service_args = service_args or [] if log_path: self.service_args.append(f"--log-path={log_path}") diff --git a/py/selenium/webdriver/chromium/webdriver.py b/py/selenium/webdriver/chromium/webdriver.py index 6ab6c447a64e6..259e3dba5ce9a 100644 --- a/py/selenium/webdriver/chromium/webdriver.py +++ b/py/selenium/webdriver/chromium/webdriver.py @@ -45,7 +45,7 @@ def __init__( service_log_path=DEFAULT_SERVICE_LOG_PATH, service: Service = None, keep_alive=DEFAULT_KEEP_ALIVE, - ): + ) -> None: """ Creates a new WebDriver instance of the ChromiumDriver. Starts the service and then creates new WebDriver instance of ChromiumDriver. diff --git a/py/selenium/webdriver/edge/service.py b/py/selenium/webdriver/edge/service.py index 603dc1e353b6f..0ea20b6e1e463 100644 --- a/py/selenium/webdriver/edge/service.py +++ b/py/selenium/webdriver/edge/service.py @@ -43,7 +43,7 @@ def __init__( log_path: typing.Optional[str] = None, service_args: typing.Optional[typing.List[str]] = None, env: typing.Optional[typing.Mapping[str, str]] = None, - ): + ) -> None: self.service_args = service_args or [] if verbose: diff --git a/py/selenium/webdriver/edge/webdriver.py b/py/selenium/webdriver/edge/webdriver.py index d1fcc9355a1dc..737915e8ed4af 100644 --- a/py/selenium/webdriver/edge/webdriver.py +++ b/py/selenium/webdriver/edge/webdriver.py @@ -44,8 +44,8 @@ def __init__( service_log_path=DEFAULT_SERVICE_LOG_PATH, service: Service = None, keep_alive=False, - verbose=False, - ): + verbose=False, # Todo: Why is this now unused? + ) -> None: """ Creates a new instance of the edge driver. Starts the service and then creates new instance of edge driver. diff --git a/py/selenium/webdriver/firefox/remote_connection.py b/py/selenium/webdriver/firefox/remote_connection.py index 8df6ae9fbb818..9592ad8673bd6 100644 --- a/py/selenium/webdriver/firefox/remote_connection.py +++ b/py/selenium/webdriver/firefox/remote_connection.py @@ -23,7 +23,7 @@ class FirefoxRemoteConnection(RemoteConnection): browser_name = DesiredCapabilities.FIREFOX["browserName"] - def __init__(self, remote_server_addr, keep_alive=True, ignore_proxy=False): + def __init__(self, remote_server_addr, keep_alive=True, ignore_proxy=False) -> None: super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy) self._commands["GET_CONTEXT"] = ("GET", "/session/$sessionId/moz/context") diff --git a/py/selenium/webdriver/firefox/service.py b/py/selenium/webdriver/firefox/service.py index b1aaaed5e932b..12d8e0e642023 100644 --- a/py/selenium/webdriver/firefox/service.py +++ b/py/selenium/webdriver/firefox/service.py @@ -42,7 +42,7 @@ def __init__( service_args: typing.Optional[typing.List[str]] = None, log_path: typing.Optional[str] = None, env: typing.Optional[typing.Mapping[str, str]] = None, - ): + ) -> None: # Todo: This is vastly inconsistent, requires a follow up to standardise. file = log_path or "geckodriver.log" log_file = open(file, "a+", encoding="utf-8") diff --git a/py/selenium/webdriver/firefox/webdriver.py b/py/selenium/webdriver/firefox/webdriver.py index 13bbd9db8fe14..42a4ee570bc7b 100644 --- a/py/selenium/webdriver/firefox/webdriver.py +++ b/py/selenium/webdriver/firefox/webdriver.py @@ -55,8 +55,8 @@ def __init__( service=None, desired_capabilities=None, log_path=DEFAULT_LOG_PATH, - keep_alive=True, - ): + keep_alive=True, # Todo: Why is this now unused? + ) -> None: """Starts a new local session of Firefox. Based on the combination and specificity of the various keyword diff --git a/py/selenium/webdriver/ie/options.py b/py/selenium/webdriver/ie/options.py index 4c443bb879146..6baf4b3a201a2 100644 --- a/py/selenium/webdriver/ie/options.py +++ b/py/selenium/webdriver/ie/options.py @@ -48,7 +48,7 @@ class Options(ArgOptions): ATTACH_TO_EDGE_CHROME = "ie.edgechromium" EDGE_EXECUTABLE_PATH = "ie.edgepath" - def __init__(self): + def __init__(self) -> None: super().__init__() self._options = {} self._additional = {} diff --git a/py/selenium/webdriver/ie/service.py b/py/selenium/webdriver/ie/service.py index 89db134cf7425..8386620b50b11 100644 --- a/py/selenium/webdriver/ie/service.py +++ b/py/selenium/webdriver/ie/service.py @@ -34,7 +34,7 @@ def __init__( host: typing.Optional[str] = None, log_level: typing.Optional[str] = None, log_file: typing.Optional[str] = None, - ): + ) -> None: """ Creates a new instance of the Service diff --git a/py/selenium/webdriver/ie/webdriver.py b/py/selenium/webdriver/ie/webdriver.py index bc11c7104e416..224a1f9c3a209 100644 --- a/py/selenium/webdriver/ie/webdriver.py +++ b/py/selenium/webdriver/ie/webdriver.py @@ -48,7 +48,7 @@ def __init__( service: Service = None, desired_capabilities=None, keep_alive=DEFAULT_KEEP_ALIVE, - ): + ) -> None: """ Creates a new instance of the Ie driver. diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index e0f24adec6762..2c66793f04ba2 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -210,7 +210,7 @@ def __init__( keep_alive=True, file_detector=None, options: Union[BaseOptions, List[BaseOptions]] = None, - ): + ) -> None: """ Create a new driver that will issue commands using the wire protocol. diff --git a/py/selenium/webdriver/remote/webelement.py b/py/selenium/webdriver/remote/webelement.py index 35adb23fe5d5a..c113d294c84fa 100644 --- a/py/selenium/webdriver/remote/webelement.py +++ b/py/selenium/webdriver/remote/webelement.py @@ -64,12 +64,12 @@ class WebElement(BaseWebElement): performed through this interface. All method calls will do a freshness check to ensure that the element - reference is still valid. This essentially determines whether or not the + reference is still valid. This essentially determines whether the element is still attached to the DOM. If this test fails, then an ``StaleElementReferenceException`` is thrown, and all future calls to this instance will fail.""" - def __init__(self, parent, id_): + def __init__(self, parent, id_) -> None: self._parent = parent self._id = id_ diff --git a/py/selenium/webdriver/safari/remote_connection.py b/py/selenium/webdriver/safari/remote_connection.py index 1f0bf156b01c9..dc1cf7c69fbe1 100644 --- a/py/selenium/webdriver/safari/remote_connection.py +++ b/py/selenium/webdriver/safari/remote_connection.py @@ -23,7 +23,7 @@ class SafariRemoteConnection(RemoteConnection): browser_name = DesiredCapabilities.SAFARI["browserName"] - def __init__(self, remote_server_addr: str, keep_alive: bool = True, ignore_proxy: bool = False): + def __init__(self, remote_server_addr: str, keep_alive: bool = True, ignore_proxy: bool = False) -> None: super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy) self._commands["GET_PERMISSIONS"] = ("GET", "/session/$sessionId/apple/permissions") self._commands["SET_PERMISSIONS"] = ("POST", "/session/$sessionId/apple/permissions") diff --git a/py/selenium/webdriver/safari/service.py b/py/selenium/webdriver/safari/service.py index 3182eef8231c5..f9eb4524f9c2f 100644 --- a/py/selenium/webdriver/safari/service.py +++ b/py/selenium/webdriver/safari/service.py @@ -42,7 +42,7 @@ def __init__( quiet: bool = False, service_args: typing.Optional[typing.List[str]] = None, env: typing.Optional[typing.Mapping[str, str]] = None, - ): + ) -> None: self._check_executable(executable_path) self.service_args = service_args or [] self.quiet = quiet diff --git a/py/selenium/webdriver/safari/webdriver.py b/py/selenium/webdriver/safari/webdriver.py index 6031d68929952..ad4409b034737 100644 --- a/py/selenium/webdriver/safari/webdriver.py +++ b/py/selenium/webdriver/safari/webdriver.py @@ -47,7 +47,7 @@ def __init__( service_args=None, options: Options = None, service: Service = None, - ): + ) -> None: """ Creates a new Safari driver instance and launches or finds a running safaridriver service.