diff --git a/py/selenium/webdriver/chrome/service.py b/py/selenium/webdriver/chrome/service.py index a16692664ba60..bc6d3f00fb1e9 100644 --- a/py/selenium/webdriver/chrome/service.py +++ b/py/selenium/webdriver/chrome/service.py @@ -16,8 +16,8 @@ # under the License. -from collections.abc import Mapping -from typing import Optional, Sequence +from collections.abc import Mapping, Sequence +from typing import Optional from selenium.types import SubprocessStdAlias from selenium.webdriver.chromium import service diff --git a/py/selenium/webdriver/chromium/service.py b/py/selenium/webdriver/chromium/service.py index a428648f8ef9b..80c79c56ca993 100644 --- a/py/selenium/webdriver/chromium/service.py +++ b/py/selenium/webdriver/chromium/service.py @@ -15,9 +15,9 @@ # specific language governing permissions and limitations # under the License. -from collections.abc import Mapping +from collections.abc import Mapping, Sequence from io import IOBase -from typing import Optional, Sequence +from typing import Optional from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service diff --git a/py/selenium/webdriver/common/bidi/script.py b/py/selenium/webdriver/common/bidi/script.py index 76f5c25722dda..a5bc234eb1536 100644 --- a/py/selenium/webdriver/common/bidi/script.py +++ b/py/selenium/webdriver/common/bidi/script.py @@ -16,7 +16,7 @@ # under the License. from dataclasses import dataclass -from typing import Any, Dict, List, Optional +from typing import Any, Optional from selenium.webdriver.common.bidi.common import command_builder @@ -55,7 +55,7 @@ class RealmInfo: sandbox: Optional[str] = None @classmethod - def from_json(cls, json: Dict[str, Any]) -> "RealmInfo": + def from_json(cls, json: dict[str, Any]) -> "RealmInfo": """Creates a RealmInfo instance from a dictionary. Parameters: @@ -90,7 +90,7 @@ class Source: context: Optional[str] = None @classmethod - def from_json(cls, json: Dict[str, Any]) -> "Source": + def from_json(cls, json: dict[str, Any]) -> "Source": """Creates a Source instance from a dictionary. Parameters: @@ -120,7 +120,7 @@ class EvaluateResult: exception_details: Optional[dict] = None @classmethod - def from_json(cls, json: Dict[str, Any]) -> "EvaluateResult": + def from_json(cls, json: dict[str, Any]) -> "EvaluateResult": """Creates an EvaluateResult instance from a dictionary. Parameters: @@ -155,7 +155,7 @@ def __init__(self, channel: str, data: dict, source: Source): self.source = source @classmethod - def from_json(cls, json: Dict[str, Any]) -> "ScriptMessage": + def from_json(cls, json: dict[str, Any]) -> "ScriptMessage": """Creates a ScriptMessage instance from a dictionary. Parameters: @@ -189,7 +189,7 @@ def __init__(self, realm_info: RealmInfo): self.realm_info = realm_info @classmethod - def from_json(cls, json: Dict[str, Any]) -> "RealmCreated": + def from_json(cls, json: dict[str, Any]) -> "RealmCreated": """Creates a RealmCreated instance from a dictionary. Parameters: @@ -212,7 +212,7 @@ def __init__(self, realm: str): self.realm = realm @classmethod - def from_json(cls, json: Dict[str, Any]) -> "RealmDestroyed": + def from_json(cls, json: dict[str, Any]) -> "RealmDestroyed": """Creates a RealmDestroyed instance from a dictionary. Parameters: @@ -262,9 +262,9 @@ def remove_console_message_handler(self, id): def _add_preload_script( self, function_declaration: str, - arguments: Optional[List[Dict[str, Any]]] = None, - contexts: Optional[List[str]] = None, - user_contexts: Optional[List[str]] = None, + arguments: Optional[list[dict[str, Any]]] = None, + contexts: Optional[list[str]] = None, + user_contexts: Optional[list[str]] = None, sandbox: Optional[str] = None, ) -> str: """Adds a preload script. @@ -288,7 +288,7 @@ def _add_preload_script( if contexts is not None and user_contexts is not None: raise ValueError("Cannot specify both contexts and user_contexts") - params: Dict[str, Any] = {"functionDeclaration": function_declaration} + params: dict[str, Any] = {"functionDeclaration": function_declaration} if arguments is not None: params["arguments"] = arguments @@ -312,7 +312,7 @@ def _remove_preload_script(self, script_id: str) -> None: params = {"script": script_id} self.conn.execute(command_builder("script.removePreloadScript", params)) - def _disown(self, handles: List[str], target: dict) -> None: + def _disown(self, handles: list[str], target: dict) -> None: """Disowns the given handles. Parameters: @@ -331,7 +331,7 @@ def _call_function( function_declaration: str, await_promise: bool, target: dict, - arguments: Optional[List[dict]] = None, + arguments: Optional[list[dict]] = None, result_ownership: Optional[str] = None, serialization_options: Optional[dict] = None, this: Optional[dict] = None, @@ -416,7 +416,7 @@ def _get_realms( self, context: Optional[str] = None, type: Optional[str] = None, - ) -> List[RealmInfo]: + ) -> list[RealmInfo]: """Returns a list of all realms, optionally filtered. Parameters: diff --git a/py/selenium/webdriver/edge/service.py b/py/selenium/webdriver/edge/service.py index f9171e0d46ba1..ef53f24d8f86b 100644 --- a/py/selenium/webdriver/edge/service.py +++ b/py/selenium/webdriver/edge/service.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. -from collections.abc import Mapping -from typing import Optional, Sequence +from collections.abc import Mapping, Sequence +from typing import Optional from selenium.types import SubprocessStdAlias from selenium.webdriver.chromium import service diff --git a/py/selenium/webdriver/firefox/service.py b/py/selenium/webdriver/firefox/service.py index 4e0180d1100c5..ce5eb96e60d60 100644 --- a/py/selenium/webdriver/firefox/service.py +++ b/py/selenium/webdriver/firefox/service.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. -from collections.abc import Mapping -from typing import Optional, Sequence +from collections.abc import Mapping, Sequence +from typing import Optional from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service, utils diff --git a/py/selenium/webdriver/ie/service.py b/py/selenium/webdriver/ie/service.py index 53b3f4bd1c237..be00ff3e64995 100644 --- a/py/selenium/webdriver/ie/service.py +++ b/py/selenium/webdriver/ie/service.py @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Optional, Sequence +from collections.abc import Sequence +from typing import Optional from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index bba1b8112b704..62ce619105186 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -29,7 +29,7 @@ from base64 import b64decode, urlsafe_b64encode from contextlib import asynccontextmanager, contextmanager from importlib import import_module -from typing import Any, Dict, Optional, Type, Union, cast +from typing import Any, Optional, Union, cast from selenium.common.exceptions import ( InvalidArgumentException, @@ -136,7 +136,7 @@ def get_remote_connection( def create_matches(options: list[BaseOptions]) -> dict: - capabilities: Dict[str, Any] = {"capabilities": {}} + capabilities: dict[str, Any] = {"capabilities": {}} opts = [] for opt in options: opts.append(opt.to_capabilities()) @@ -201,7 +201,7 @@ def __init__( file_detector: Optional[FileDetector] = None, options: Optional[Union[BaseOptions, list[BaseOptions]]] = None, locator_converter: Optional[LocatorConverter] = None, - web_element_cls: Optional[Type[WebElement]] = None, + web_element_cls: Optional[type[WebElement]] = None, client_config: Optional[ClientConfig] = None, ) -> None: """Create a new driver that will issue commands using the wire @@ -248,8 +248,8 @@ def __init__( ) self._is_remote = True self.session_id: Optional[str] = None - self.caps: Dict[str, Any] = {} - self.pinned_scripts: Dict[str, Any] = {} + self.caps: dict[str, Any] = {} + self.pinned_scripts: dict[str, Any] = {} self.error_handler = ErrorHandler() self._switch_to = SwitchTo(self) self._mobile = Mobile(self) @@ -668,7 +668,7 @@ def print_page(self, print_options: Optional[PrintOptions] = None) -> str: -------- >>> driver.print_page() """ - options: Union[Dict[str, Any], Any] = {} + options: Union[dict[str, Any], Any] = {} if print_options: options = print_options.to_dict() diff --git a/py/selenium/webdriver/safari/service.py b/py/selenium/webdriver/safari/service.py index 89c3afe53d203..eeb6a57948cf3 100644 --- a/py/selenium/webdriver/safari/service.py +++ b/py/selenium/webdriver/safari/service.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. -from collections.abc import Mapping -from typing import Optional, Sequence +from collections.abc import Mapping, Sequence +from typing import Optional from selenium.webdriver.common import service diff --git a/py/selenium/webdriver/webkitgtk/service.py b/py/selenium/webdriver/webkitgtk/service.py index 5e7d181aa2dcc..3017ffd241da3 100644 --- a/py/selenium/webdriver/webkitgtk/service.py +++ b/py/selenium/webdriver/webkitgtk/service.py @@ -17,8 +17,8 @@ import shutil import warnings -from collections.abc import Mapping -from typing import Optional, Sequence +from collections.abc import Mapping, Sequence +from typing import Optional from selenium.webdriver.common import service diff --git a/py/selenium/webdriver/wpewebkit/service.py b/py/selenium/webdriver/wpewebkit/service.py index 2941633aa91bb..2ad99e77a54a6 100644 --- a/py/selenium/webdriver/wpewebkit/service.py +++ b/py/selenium/webdriver/wpewebkit/service.py @@ -16,8 +16,8 @@ # under the License. import shutil -from collections.abc import Mapping -from typing import Optional, Sequence +from collections.abc import Mapping, Sequence +from typing import Optional from selenium.webdriver.common import service