Skip to content

Commit 51211f2

Browse files
authored
[keyboard] Replace FloatInt with proper types (#17002)
1 parent 6784c13 commit 51211f2

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

‎stubs/keyboard/keyboard/__init__.pyi‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from _typeshed import FloatInt
21
from collections.abc import Callable, Generator, Iterable, Sequence
32
from queue import Queue
43
from threading import Event as _UninterruptibleEvent
@@ -33,7 +32,7 @@ def release(hotkey: _ParseableHotkey) -> None: ...
3332
# is_pressed cannot check multi-step hotkeys, so not using _ParseableHotkey
3433

3534
def is_pressed(hotkey: _Key | _ScanCodeList) -> bool: ...
36-
def call_later(fn: Callable[..., None], args: _Ts = (), delay: FloatInt = 0.001) -> None: ...
35+
def call_later(fn: Callable[..., None], args: _Ts = (), delay: float | int = 0.001) -> None: ...
3736
def hook(callback: _Callback, suppress: bool = False, on_remove: Callable[[], None] = ...) -> Callable[[], None]: ...
3837
def on_press(callback: _Callback, suppress: bool = False) -> Callable[[], None]: ...
3938
def on_release(callback: _Callback, suppress: bool = False) -> Callable[[], None]: ...
@@ -97,7 +96,7 @@ def start_recording(
9796
) -> tuple[Queue[KeyboardEvent], Callable[[], None]]: ...
9897
def stop_recording() -> list[KeyboardEvent]: ...
9998
def record(until: str = "escape", suppress: bool = False, trigger_on_release: bool = False) -> list[KeyboardEvent]: ...
100-
def play(events: Iterable[KeyboardEvent], speed_factor: FloatInt = 1.0) -> None: ...
99+
def play(events: Iterable[KeyboardEvent], speed_factor: float | int = 1.0) -> None: ...
101100

102101
replay = play
103102

‎stubs/keyboard/keyboard/_keyboard_event.pyi‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from _typeshed import FloatInt
21
from typing import Literal
32

43
from ._canonical_names import canonical_names as canonical_names, normalize_name as normalize_name
@@ -10,7 +9,7 @@ class KeyboardEvent:
109
event_type: Literal["down", "up"] | None
1110
scan_code: int
1211
name: str | None
13-
time: FloatInt | None
12+
time: float | int | None
1413
device: str | None
1514
modifiers: tuple[str, ...] | None
1615
is_keypad: bool | None
@@ -20,7 +19,7 @@ class KeyboardEvent:
2019
event_type: Literal["down", "up"] | None,
2120
scan_code: int,
2221
name: str | None = None,
23-
time: FloatInt | None = None,
22+
time: float | int | None = None,
2423
device: str | None = None,
2524
modifiers: tuple[str, ...] | None = None,
2625
is_keypad: bool | None = None,

‎stubs/keyboard/keyboard/_mouse_event.pyi‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sys
2-
from _typeshed import FloatInt
32
from typing import Literal, NamedTuple, TypeAlias
43

54
_MouseEvent: TypeAlias = ButtonEvent | WheelEvent | MoveEvent # noqa: Y047 # Used outside
@@ -31,13 +30,13 @@ else:
3130
class ButtonEvent(NamedTuple):
3231
event_type: _MouseEventType
3332
button: _MouseButton
34-
time: FloatInt
33+
time: float
3534

3635
class WheelEvent(NamedTuple):
3736
delta: int
38-
time: FloatInt
37+
time: float
3938

4039
class MoveEvent(NamedTuple):
4140
x: int
4241
y: int
43-
time: FloatInt
42+
time: float

‎stubs/keyboard/keyboard/mouse.pyi‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sys
2-
from _typeshed import FloatInt
32
from collections.abc import Callable, Iterable
43
from ctypes import c_long
54
from typing import Literal, SupportsInt, TypeAlias, TypeVar
@@ -74,7 +73,7 @@ def unhook_all() -> None: ...
7473
def record(button: _MouseButton = "right", target_types: tuple[_MouseEventType] = ("down",)) -> _MouseEvent: ...
7574
def play(
7675
events: Iterable[_MouseEvent],
77-
speed_factor: FloatInt = 1.0,
76+
speed_factor: float | int = 1.0,
7877
include_clicks: bool = True,
7978
include_moves: bool = True,
8079
include_wheel: bool = True,

0 commit comments

Comments
 (0)