Skip to content

Commit 14b1bef

Browse files
committed
[py]: Additional type hinting for actions
1 parent 179ea5d commit 14b1bef

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

py/selenium/webdriver/common/actions/key_actions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
from __future__ import annotations
18+
1719
from ..utils import keys_to_typing
1820
from .interaction import KEY
1921
from .interaction import Interaction
@@ -44,7 +46,7 @@ def send_keys(self, text):
4446
self.key_up(letter)
4547
return self
4648

47-
def _key_action(self, action, letter):
49+
def _key_action(self, action, letter) -> KeyActions:
4850
meth = getattr(self.source, action)
4951
meth(letter)
5052
return self

py/selenium/webdriver/common/actions/key_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def create_key_down(self, key) -> None:
3535
def create_key_up(self, key) -> None:
3636
self.add_action(TypingInteraction(self, "keyUp", key))
3737

38-
def create_pause(self, pause_duration=0) -> None:
38+
def create_pause(self, pause_duration: float = 0) -> None:
3939
self.add_action(Pause(self, pause_duration))
4040

4141

py/selenium/webdriver/common/actions/pointer_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def double_click(self, element=None):
194194
self.pointer_up(MouseButton.LEFT)
195195
return self
196196

197-
def pause(self, duration=0):
197+
def pause(self, duration: float = 0):
198198
self.source.create_pause(duration)
199199
return self
200200

py/selenium/webdriver/common/actions/pointer_input.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ def __init__(self, kind, name):
3535
self.kind = kind
3636
self.name = name
3737

38-
def create_pointer_move(self, duration=DEFAULT_MOVE_DURATION, x=0, y=0, origin=None, **kwargs):
38+
def create_pointer_move(
39+
self,
40+
duration=DEFAULT_MOVE_DURATION,
41+
x: float = 0,
42+
y: float = 0,
43+
origin: typing.Optional[WebElement] = None,
44+
**kwargs,
45+
):
3946
action = {"type": "pointerMove", "duration": duration, "x": x, "y": y, **kwargs}
4047
if isinstance(origin, WebElement):
4148
action["origin"] = {"element-6066-11e4-a52e-4f735466cecf": origin.id}
@@ -53,7 +60,7 @@ def create_pointer_up(self, button):
5360
def create_pointer_cancel(self):
5461
self.add_action({"type": "pointerCancel"})
5562

56-
def create_pause(self, pause_duration):
63+
def create_pause(self, pause_duration: float) -> None:
5764
self.add_action({"type": "pause", "duration": int(pause_duration * 1000)})
5865

5966
def encode(self):

py/selenium/webdriver/common/actions/wheel_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, source: WheelInput = None):
2424
source = WheelInput("wheel")
2525
super().__init__(source)
2626

27-
def pause(self, duration=0):
27+
def pause(self, duration: float = 0):
2828
self.source.create_pause(duration)
2929
return self
3030

py/selenium/webdriver/common/actions/wheel_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ def create_scroll(self, x: int, y: int, delta_x: int, delta_y: int, duration: in
7373
}
7474
)
7575

76-
def create_pause(self, pause_duration: Union[int, float]) -> None:
76+
def create_pause(self, pause_duration: float) -> None:
7777
self.add_action({"type": "pause", "duration": int(pause_duration * 1000)})

0 commit comments

Comments
 (0)