From df51ab327f43b2b20d919580e58a7bbcddc7f09d Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Tue, 19 Aug 2025 13:14:48 +0530 Subject: [PATCH 1/3] fixed mypy issues in action builder file --- .../webdriver/common/actions/action_builder.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/py/selenium/webdriver/common/actions/action_builder.py b/py/selenium/webdriver/common/actions/action_builder.py index 211217edd7140..cfb0d6f65449a 100644 --- a/py/selenium/webdriver/common/actions/action_builder.py +++ b/py/selenium/webdriver/common/actions/action_builder.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from typing import Optional, Union + from selenium.webdriver.remote.command import Command @@ -26,6 +26,7 @@ from .pointer_input import PointerInput from .wheel_actions import WheelActions from .wheel_input import WheelInput +from typing import Optional, Union, Dict, List, Any class ActionBuilder: @@ -40,7 +41,7 @@ def __init__( mouse = mouse or PointerInput(interaction.POINTER_MOUSE, "mouse") keyboard = keyboard or KeyInput(interaction.KEY) wheel = wheel or WheelInput(interaction.WHEEL) - self.devices = [mouse, keyboard, wheel] + self.devices: List[Union[PointerInput, KeyInput, WheelInput]] = [mouse, keyboard, wheel] self._key_action = KeyActions(keyboard) self._pointer_action = PointerActions(mouse, duration=duration) self._wheel_action = WheelActions(wheel) @@ -62,11 +63,11 @@ def get_device_with(self, name: str) -> Optional[Union["WheelInput", "PointerInp @property def pointer_inputs(self) -> list[PointerInput]: - return [device for device in self.devices if device.type == interaction.POINTER] + return [device for device in self.devices if isinstance(device, PointerInput)] @property def key_inputs(self) -> list[KeyInput]: - return [device for device in self.devices if device.type == interaction.KEY] + return [device for device in self.devices if isinstance(device, KeyInput)] @property def key_action(self) -> KeyActions: @@ -159,7 +160,7 @@ def perform(self) -> None: >>> el = driver.find_element(id: "some_id") >>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys").perform() """ - enc = {"actions": []} + enc: Dict[str, List[Any]] = {"actions": []} for device in self.devices: encoded = device.encode() if encoded["actions"]: From b849459d30895b5e7ff1d2d4bc11a609923c3c9b Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Wed, 20 Aug 2025 12:52:05 +0530 Subject: [PATCH 2/3] fixed linting error --- py/selenium/webdriver/common/actions/action_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/selenium/webdriver/common/actions/action_builder.py b/py/selenium/webdriver/common/actions/action_builder.py index cfb0d6f65449a..1c20031c2e1ff 100644 --- a/py/selenium/webdriver/common/actions/action_builder.py +++ b/py/selenium/webdriver/common/actions/action_builder.py @@ -16,6 +16,7 @@ # under the License. +from typing import Any, Dict, List, Optional, Union from selenium.webdriver.remote.command import Command @@ -26,7 +27,6 @@ from .pointer_input import PointerInput from .wheel_actions import WheelActions from .wheel_input import WheelInput -from typing import Optional, Union, Dict, List, Any class ActionBuilder: From 745389d086b317f2f51ef2992c10ac036ac4bc81 Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Wed, 20 Aug 2025 22:37:15 +0530 Subject: [PATCH 3/3] modified dict and list to take from built in libraries --- py/selenium/webdriver/common/actions/action_builder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/selenium/webdriver/common/actions/action_builder.py b/py/selenium/webdriver/common/actions/action_builder.py index 1c20031c2e1ff..48859832de0e7 100644 --- a/py/selenium/webdriver/common/actions/action_builder.py +++ b/py/selenium/webdriver/common/actions/action_builder.py @@ -16,7 +16,7 @@ # under the License. -from typing import Any, Dict, List, Optional, Union +from typing import Any, Optional, Union from selenium.webdriver.remote.command import Command @@ -41,7 +41,7 @@ def __init__( mouse = mouse or PointerInput(interaction.POINTER_MOUSE, "mouse") keyboard = keyboard or KeyInput(interaction.KEY) wheel = wheel or WheelInput(interaction.WHEEL) - self.devices: List[Union[PointerInput, KeyInput, WheelInput]] = [mouse, keyboard, wheel] + self.devices: list[Union[PointerInput, KeyInput, WheelInput]] = [mouse, keyboard, wheel] self._key_action = KeyActions(keyboard) self._pointer_action = PointerActions(mouse, duration=duration) self._wheel_action = WheelActions(wheel) @@ -160,7 +160,7 @@ def perform(self) -> None: >>> el = driver.find_element(id: "some_id") >>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys").perform() """ - enc: Dict[str, List[Any]] = {"actions": []} + enc: dict[str, list[Any]] = {"actions": []} for device in self.devices: encoded = device.encode() if encoded["actions"]: