Skip to content

Commit 8ac0e1a

Browse files
authored
fix: ScrapflyReader Pydantic validation error (#19999)
1 parent 3040253 commit 8ac0e1a

File tree

2 files changed

+12
-5
lines changed
  • llama-index-integrations/readers/llama-index-readers-web

2 files changed

+12
-5
lines changed

llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/scrapfly_web/base.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"""Scrapfly Web Reader."""
22

33
import logging
4-
from typing import List, Optional, Literal
4+
from typing import List, Optional, Literal, TYPE_CHECKING
55

66
from llama_index.core.readers.base import BasePydanticReader
77
from llama_index.core.schema import Document
88

9+
if TYPE_CHECKING:
10+
from scrapfly import ScrapflyClient
11+
912
logger = logging.getLogger(__file__)
1013

1114

@@ -25,18 +28,22 @@ class ScrapflyReader(BasePydanticReader):
2528

2629
api_key: str
2730
ignore_scrape_failures: bool = True
28-
scrapfly: Optional["ScrapflyClient"] = None # Declare the scrapfly attribute
31+
scrapfly: "ScrapflyClient"
2932

3033
def __init__(self, api_key: str, ignore_scrape_failures: bool = True) -> None:
3134
"""Initialize client."""
32-
super().__init__(api_key=api_key, ignore_scrape_failures=ignore_scrape_failures)
3335
try:
3436
from scrapfly import ScrapflyClient
3537
except ImportError:
3638
raise ImportError(
3739
"`scrapfly` package not found, please run `pip install scrapfly-sdk`"
3840
)
39-
self.scrapfly = ScrapflyClient(key=api_key)
41+
scrapfly = ScrapflyClient(key=api_key)
42+
super().__init__(
43+
api_key=api_key,
44+
ignore_scrape_failures=ignore_scrape_failures,
45+
scrapfly=scrapfly,
46+
)
4047

4148
@classmethod
4249
def class_name(cls) -> str:

llama-index-integrations/readers/llama-index-readers-web/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dev = [
2626

2727
[project]
2828
name = "llama-index-readers-web"
29-
version = "0.5.4"
29+
version = "0.5.5"
3030
description = "llama-index readers web integration"
3131
authors = [{name = "Your Name", email = "[email protected]"}]
3232
requires-python = ">=3.9,<4.0"

0 commit comments

Comments
 (0)