Skip to content

Commit

Permalink
Adjust typing for PageMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
elacuesta committed Sep 18, 2024
1 parent f6201db commit 5cf130c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scrapy_playwright/page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Any, Callable
from typing import Any, Callable, Union

from playwright.async_api import Page


__all__ = ["PageMethod"]
Expand All @@ -8,10 +10,12 @@ class PageMethod:
"""
Represents a method to be called (and awaited if necessary) on a
Playwright page, such as "click", "screenshot", "evaluate", etc.
If a callable is received, it will be called with the page as its only argument.
"""

def __init__(self, method: str | Callable, *args, **kwargs) -> None:
self.method: str | Callable = method
def __init__(self, method: Union[str, Callable[[Page], Any]], *args, **kwargs) -> None:
self.method: Union[str, Callable[[Page], Any]] = method
self.args: tuple = args
self.kwargs: dict = kwargs
self.result: Any = None
Expand Down

0 comments on commit 5cf130c

Please sign in to comment.