Skip to content

Commit

Permalink
use optional for python 3.9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
MQ37 committed Jan 31, 2025
1 parent b601072 commit bcdcb88
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions langchain_apify/document_loaders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Apify document loader."""

from typing import Any, Callable, Iterator
from typing import Any, Callable, Iterator, Optional

from apify_client import ApifyClient
from langchain_core.document_loaders.base import BaseLoader
Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(
self,
dataset_id: str,
dataset_mapping_function: Callable[[dict], Document],
apify_api_token: str | None = None,
apify_api_token: Optional[str] = None,
):
"""Initialize the loader with an Apify dataset ID and a mapping function.
Expand Down
6 changes: 3 additions & 3 deletions langchain_apify/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
import os
from typing import Any
from typing import Any, Optional

from apify_client import ApifyClient
from langchain_core.callbacks import (
Expand Down Expand Up @@ -56,7 +56,7 @@ class ApifyActorsTool(BaseTool): # type: ignore[override, override]
def __init__(
self,
actor_id: str,
apify_api_token: str | None = None,
apify_api_token: Optional[str] = None,
*args: Any,
**kwargs: Any,
) -> None:
Expand Down Expand Up @@ -89,7 +89,7 @@ def __init__(
def _run(
self,
run_input: str | dict,
run_manager: CallbackManagerForToolRun | None = None,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> list[dict]:
"""Use the Apify Actor."""
input_dict = json.loads(run_input) if isinstance(run_input, str) else run_input
Expand Down
30 changes: 15 additions & 15 deletions langchain_apify/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable
from typing import Any, Callable, Optional

from apify_client import ApifyClient, ApifyClientAsync
from langchain_core.documents import Document
Expand Down Expand Up @@ -48,11 +48,11 @@ class ApifyWrapper(BaseModel):

apify_client: ApifyClient
apify_client_async: ApifyClientAsync
apify_api_token: str | None = None
apify_api_token: Optional[str] = None

def __init__(
self,
apify_api_token: str | None = None,
apify_api_token: Optional[str] = None,
*args: Any,
**kwargs: Any,
):
Expand Down Expand Up @@ -98,9 +98,9 @@ def call_actor(
run_input: dict,
dataset_mapping_function: Callable[[dict], Document],
*,
build: str | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
build: Optional[str] = None,
memory_mbytes: Optional[int] = None,
timeout_secs: Optional[int] = None,
) -> "ApifyDatasetLoader":
"""Run an Actor on the Apify platform and wait for results to be ready.
Args:
Expand Down Expand Up @@ -140,9 +140,9 @@ async def acall_actor(
run_input: dict,
dataset_mapping_function: Callable[[dict], Document],
*,
build: str | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
build: Optional[str] = None,
memory_mbytes: Optional[int] = None,
timeout_secs: Optional[int] = None,
) -> "ApifyDatasetLoader":
"""Run an Actor on the Apify platform and wait for results to be ready.
Args:
Expand Down Expand Up @@ -182,9 +182,9 @@ def call_actor_task(
task_input: dict,
dataset_mapping_function: Callable[[dict], Document],
*,
build: str | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
build: Optional[str] = None,
memory_mbytes: Optional[int] = None,
timeout_secs: Optional[int] = None,
) -> "ApifyDatasetLoader":
"""Run a saved Actor task on Apify and wait for results to be ready.
Args:
Expand Down Expand Up @@ -225,9 +225,9 @@ async def acall_actor_task(
task_input: dict,
dataset_mapping_function: Callable[[dict], Document],
*,
build: str | None = None,
memory_mbytes: int | None = None,
timeout_secs: int | None = None,
build: Optional[str] = None,
memory_mbytes: Optional[int] = None,
timeout_secs: Optional[int] = None,
) -> "ApifyDatasetLoader":
"""Run a saved Actor task on Apify and wait for results to be ready.
Args:
Expand Down

0 comments on commit bcdcb88

Please sign in to comment.