diff --git a/py/pyproject.toml b/py/pyproject.toml index 8a8d4a950b3a7..4b0080a95afa5 100644 --- a/py/pyproject.toml +++ b/py/pyproject.toml @@ -125,11 +125,10 @@ warn_unused_ignores = true # warns when returning a value with typing.Any from a function with a non typing.Any return type. warn_return_any = false # Shows a warning when encountering any code inferred to be unreachable after performing type analysis. -warn_unreachable = false +warn_unreachable = true [[tool.mypy.overrides]] module = [ - "selenium.webdriver.common.devtools.*", "selenium.webdriver.common.bidi.*", ] ignore_errors = true diff --git a/py/selenium/webdriver/common/_bidi/serialization.py b/py/selenium/webdriver/common/_bidi/serialization.py index 84d251da857eb..09b0984bd3006 100644 --- a/py/selenium/webdriver/common/_bidi/serialization.py +++ b/py/selenium/webdriver/common/_bidi/serialization.py @@ -291,7 +291,7 @@ def as_json(self) -> dict: return payload @classmethod - def from_json(cls, payload: dict) -> Any: + def from_json(cls, payload: Any) -> Any: if not isinstance(payload, dict): got = type(payload).__name__ raise BiDiSerializationError(f"{cls.__name__} expected an object on the wire, got {got} {payload!r}") diff --git a/py/selenium/webdriver/common/actions/pointer_input.py b/py/selenium/webdriver/common/actions/pointer_input.py index 448b2c6b18390..d4d1fb837f397 100644 --- a/py/selenium/webdriver/common/actions/pointer_input.py +++ b/py/selenium/webdriver/common/actions/pointer_input.py @@ -39,7 +39,7 @@ def create_pointer_move( duration=DEFAULT_MOVE_DURATION, x: float = 0, y: float = 0, - origin: WebElement | None = None, + origin: WebElement | str | None = None, **kwargs, ): action = {"type": "pointerMove", "duration": duration, "x": x, "y": y, **kwargs} diff --git a/py/selenium/webdriver/common/proxy.py b/py/selenium/webdriver/common/proxy.py index eadf1d069709f..5cc34c0c7bf14 100644 --- a/py/selenium/webdriver/common/proxy.py +++ b/py/selenium/webdriver/common/proxy.py @@ -74,16 +74,16 @@ def __set__(self, obj, value): class Proxy: """Proxy configuration containing proxy type and necessary proxy settings.""" - proxyType = ProxyType.UNSPECIFIED - autodetect = False - httpProxy = "" - noProxy = "" - proxyAutoconfigUrl = "" - sslProxy = "" - socksProxy = "" - socksUsername = "" - socksPassword = "" - socksVersion = None + proxyType: dict = ProxyType.UNSPECIFIED + autodetect: bool = False + httpProxy: str = "" + noProxy: str | list[str] = "" + proxyAutoconfigUrl: str = "" + sslProxy: str = "" + socksProxy: str = "" + socksUsername: str = "" + socksPassword: str = "" + socksVersion: int | None = None # create descriptor type objects auto_detect = _ProxyTypeDescriptor("autodetect", ProxyType.AUTODETECT) diff --git a/py/selenium/webdriver/common/service.py b/py/selenium/webdriver/common/service.py index fa53be3988fe9..42c94ea12147e 100644 --- a/py/selenium/webdriver/common/service.py +++ b/py/selenium/webdriver/common/service.py @@ -22,7 +22,6 @@ import sys from abc import ABC, abstractmethod from collections.abc import Mapping -from io import IOBase from subprocess import PIPE from time import sleep from typing import IO, Any @@ -156,10 +155,10 @@ def send_remote_shutdown_command(self) -> None: def stop(self) -> None: """Stops the service.""" if self.log_output not in {PIPE, subprocess.DEVNULL}: - if isinstance(self.log_output, IOBase) and self._owns_log_output: - self.log_output.close() - elif isinstance(self.log_output, int): + if isinstance(self.log_output, int): os.close(self.log_output) + elif self.log_output is not None and self._owns_log_output: + self.log_output.close() if self.process is not None: try: if self.process.poll() is None: diff --git a/py/selenium/webdriver/firefox/options.py b/py/selenium/webdriver/firefox/options.py index ef3afe546fb91..598673fcfc915 100644 --- a/py/selenium/webdriver/firefox/options.py +++ b/py/selenium/webdriver/firefox/options.py @@ -24,7 +24,7 @@ class Log: def __init__(self) -> None: - self.level = None + self.level: str | None = None def to_capabilities(self) -> dict: if self.level: