Skip to content

Commit 5e52bcf

Browse files
feat: add docs for events in the generator (#897)
1 parent 9a59907 commit 5e52bcf

File tree

9 files changed

+1608
-18
lines changed

9 files changed

+1608
-18
lines changed

playwright/_impl/_async_base.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import asyncio
1616
import traceback
1717
from types import TracebackType
18-
from typing import Any, Awaitable, Callable, Generic, Type, TypeVar, Union
18+
from typing import Any, Awaitable, Callable, Generic, Type, TypeVar
1919

2020
from playwright._impl._impl_to_api_mapping import ImplToApiMapping, ImplWrapper
2121

@@ -73,19 +73,17 @@ def _wrap_handler(self, handler: Any) -> Callable[..., None]:
7373
return mapping.wrap_handler(handler)
7474
return handler
7575

76-
def on(self, event: str, f: Callable[..., Union[Awaitable[None], None]]) -> None:
76+
def on(self, event: Any, f: Any) -> None:
7777
"""Registers the function ``f`` to the event name ``event``."""
7878
self._impl_obj.on(event, self._wrap_handler(f))
7979

80-
def once(self, event: str, f: Callable[..., Union[Awaitable[None], None]]) -> None:
80+
def once(self, event: Any, f: Any) -> None:
8181
"""The same as ``self.on``, except that the listener is automatically
8282
removed after being called.
8383
"""
8484
self._impl_obj.once(event, self._wrap_handler(f))
8585

86-
def remove_listener(
87-
self, event: str, f: Callable[..., Union[Awaitable[None], None]]
88-
) -> None:
86+
def remove_listener(self, event: Any, f: Any) -> None:
8987
"""Removes the function ``f`` from ``event``."""
9088
self._impl_obj.remove_listener(event, self._wrap_handler(f))
9189

playwright/_impl/_sync_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ def _wrap_handler(self, handler: Any) -> Callable[..., None]:
115115
return mapping.wrap_handler(handler)
116116
return handler
117117

118-
def on(self, event: str, f: Callable[..., None]) -> None:
118+
def on(self, event: Any, f: Any) -> None:
119119
"""Registers the function ``f`` to the event name ``event``."""
120120
self._impl_obj.on(event, self._wrap_handler(f))
121121

122-
def once(self, event: str, f: Callable[..., None]) -> None:
122+
def once(self, event: Any, f: Any) -> None:
123123
"""The same as ``self.on``, except that the listener is automatically
124124
removed after being called.
125125
"""
126126
self._impl_obj.once(event, self._wrap_handler(f))
127127

128-
def remove_listener(self, event: str, f: Callable[..., None]) -> None:
128+
def remove_listener(self, event: Any, f: Any) -> None:
129129
"""Removes the function ``f`` from ``event``."""
130130
self._impl_obj.remove_listener(event, self._wrap_handler(f))
131131

0 commit comments

Comments
 (0)