Repository: apify/crawlee-python
File: src/crawlee/_types.py (Python)

Code before:
    """

    def __call__(
        self,
        *,
        selector: str = 'a',
        label: str | None = None,
        user_data: dict[str, Any] | None = None,
        transform_request_function: Callable[[RequestOptions], RequestOptions | Literal['skip', 'unchanged']]
        | None = None,
        **kwargs: Unpack[EnqueueLinksKwargs],
    ) -> Coroutine[None, None, None]:
        """A call dunder method.

        Args:
            selector: A selector used to find the elements containing the links. The behaviour differs based
                on the crawler used:
                - `PlaywrightCrawler` supports CSS and XPath selectors.
                - `ParselCrawler` supports CSS selectors.
                - `BeautifulSoupCrawler` supports CSS selectors.
            label: Label for the newly created `Request` objects, used for request routing.
            user_data: User data to be provided to the newly created `Request` objects.
            transform_request_function: A function that takes RequestOptions and returns either:
                - Modified RequestOptions to update the request configuration
                - 'skip' to exclude the request from being enqueued
                - 'unchanged' to use the original request options without modification
            **kwargs: Additional keyword arguments.
        """


@docs_group('Functions')
class ExportToFunction(Protocol):
    """A function for exporting data from a `Dataset`.

    It simplifies the process of exporting data from a `Dataset`. It opens the specified one and exports
    its content to a `KeyValueStore`.
    """

    def __call__(
        self,
        dataset_id: str | None = None,
        dataset_name: str | None = None,
        **kwargs: Unpack[ExportToKwargs],
    ) -> Coroutine[None, None, None]:
        """Call dunder method.

        Args:
            dataset_id: The ID of the `Dataset` to export data from.
            dataset_name: The name of the `Dataset` to export data from.
            **kwargs: Additional keyword arguments.
        """

Review comment (suggestion):
```suggestion
            transform_request_function: A function that takes `RequestOptions` and returns either:
                - Modified `RequestOptions` to update the request configuration,
                - `'skip'` to exclude the request from being enqueued,
                - `'unchanged'` to use the original request options without modification.
```

Code after:
    selectors and other options. You can also specify labels and user data to be associated with the newly
    created `Request` objects.
    """

    def __call__(
        self,
        *,
        selector: str = 'a',
        label: str | None = None,
        user_data: dict[str, Any] | None = None,
        transform_request_function: Callable[[RequestOptions], RequestOptions | RequestTransformAction] | None = None,
        **kwargs: Unpack[EnqueueLinksKwargs],
    ) -> Coroutine[None, None, None]:
        """A call dunder method.

        Args:
            selector: A selector used to find the elements containing the links. The behaviour differs based
                on the crawler used:
                - `PlaywrightCrawler` supports CSS and XPath selectors.
                - `ParselCrawler` supports CSS selectors.
                - `BeautifulSoupCrawler` supports CSS selectors.
            label: Label for the newly created `Request` objects, used for request routing.
            user_data: User data to be provided to the newly created `Request` objects.
            transform_request_function: A function that takes `RequestOptions` and returns either:
                - Modified `RequestOptions` to update the request configuration,
                - `'skip'` to exclude the request from being enqueued,
                - `'unchanged'` to use the original request options without modification.
            **kwargs: Additional keyword arguments.
        """


@docs_group('Functions')
class ExportToFunction(Protocol):
    """A function for exporting data from a `Dataset`.

    It simplifies the process of exporting data from a `Dataset`. It opens the specified one and exports
    its content to a `KeyValueStore`.
    """

    def __call__(
        self,
        dataset_id: str | None = None,
        dataset_name: str | None = None,
        **kwargs: Unpack[ExportToKwargs],
    ) -> Coroutine[None, None, None]:
        """Call dunder method.

        Args:
            dataset_id: The ID of the `Dataset` to export data from.
            dataset_name: The name of the `Dataset` to export data from.
            **kwargs: Additional keyword arguments.