Skip to content

Commit f4ff5fd

Browse files
refactor: rename ScrapeFormatEntry -> FormatConfig
The union type was awkwardly named. FormatConfig matches the naming of its members (MarkdownFormatConfig, HtmlFormatConfig, ...) and reads naturally in signatures: formats: list[FormatConfig]. Also exported from the top-level package so users can type-annotate their own code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 35e0ba3 commit f4ff5fd

4 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/scrapegraph_py/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
ExtractRequest,
1111
ExtractResponse,
1212
FetchConfig,
13+
FormatConfig,
1314
HealthResponse,
1415
HistoryEntry,
1516
HistoryFilter,
@@ -66,6 +67,7 @@
6667
"HealthResponse",
6768
"TokenUsage",
6869
"FetchConfig",
70+
"FormatConfig",
6971
"MarkdownFormatConfig",
7072
"HtmlFormatConfig",
7173
"ScreenshotFormatConfig",

src/scrapegraph_py/async_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
ExtractRequest,
2525
ExtractResponse,
2626
FetchConfig,
27+
FormatConfig,
2728
HealthResponse,
2829
HistoryEntry,
2930
HistoryFilter,
@@ -33,7 +34,6 @@
3334
MonitorCreateRequest,
3435
MonitorResponse,
3536
MonitorUpdateRequest,
36-
ScrapeFormatEntry,
3737
ScrapeRequest,
3838
ScrapeResponse,
3939
SearchRequest,
@@ -87,7 +87,7 @@ async def start(
8787
self,
8888
url: str,
8989
*,
90-
formats: list[ScrapeFormatEntry] | None = None,
90+
formats: list[FormatConfig] | None = None,
9191
max_depth: int | None = None,
9292
max_pages: int | None = None,
9393
max_links_per_page: int | None = None,
@@ -136,7 +136,7 @@ async def create(
136136
interval: str,
137137
*,
138138
name: str | None = None,
139-
formats: list[ScrapeFormatEntry] | None = None,
139+
formats: list[FormatConfig] | None = None,
140140
webhook_url: str | None = None,
141141
fetch_config: FetchConfig | None = None,
142142
) -> ApiResult[MonitorResponse]:
@@ -163,7 +163,7 @@ async def update(
163163
id: str,
164164
*,
165165
name: str | None = None,
166-
formats: list[ScrapeFormatEntry] | None = None,
166+
formats: list[FormatConfig] | None = None,
167167
webhook_url: str | None = None,
168168
interval: str | None = None,
169169
fetch_config: FetchConfig | None = None,
@@ -330,7 +330,7 @@ async def scrape(
330330
self,
331331
url: str,
332332
*,
333-
formats: list[ScrapeFormatEntry] | None = None,
333+
formats: list[FormatConfig] | None = None,
334334
fetch_config: FetchConfig | None = None,
335335
content_type: ApiFetchContentType | None = None,
336336
) -> ApiResult[ScrapeResponse]:

src/scrapegraph_py/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
ExtractRequest,
2525
ExtractResponse,
2626
FetchConfig,
27+
FormatConfig,
2728
HealthResponse,
2829
HistoryEntry,
2930
HistoryFilter,
@@ -33,7 +34,6 @@
3334
MonitorCreateRequest,
3435
MonitorResponse,
3536
MonitorUpdateRequest,
36-
ScrapeFormatEntry,
3737
ScrapeRequest,
3838
ScrapeResponse,
3939
SearchRequest,
@@ -87,7 +87,7 @@ def start(
8787
self,
8888
url: str,
8989
*,
90-
formats: list[ScrapeFormatEntry] | None = None,
90+
formats: list[FormatConfig] | None = None,
9191
max_depth: int | None = None,
9292
max_pages: int | None = None,
9393
max_links_per_page: int | None = None,
@@ -136,7 +136,7 @@ def create(
136136
interval: str,
137137
*,
138138
name: str | None = None,
139-
formats: list[ScrapeFormatEntry] | None = None,
139+
formats: list[FormatConfig] | None = None,
140140
webhook_url: str | None = None,
141141
fetch_config: FetchConfig | None = None,
142142
) -> ApiResult[MonitorResponse]:
@@ -163,7 +163,7 @@ def update(
163163
id: str,
164164
*,
165165
name: str | None = None,
166-
formats: list[ScrapeFormatEntry] | None = None,
166+
formats: list[FormatConfig] | None = None,
167167
webhook_url: str | None = None,
168168
interval: str | None = None,
169169
fetch_config: FetchConfig | None = None,
@@ -330,7 +330,7 @@ def scrape(
330330
self,
331331
url: str,
332332
*,
333-
formats: list[ScrapeFormatEntry] | None = None,
333+
formats: list[FormatConfig] | None = None,
334334
fetch_config: FetchConfig | None = None,
335335
content_type: ApiFetchContentType | None = None,
336336
) -> ApiResult[ScrapeResponse]:

src/scrapegraph_py/schemas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class BrandingFormatConfig(CamelModel):
120120
type: Literal["branding"] = "branding"
121121

122122

123-
ScrapeFormatEntry = (
123+
FormatConfig = (
124124
MarkdownFormatConfig
125125
| HtmlFormatConfig
126126
| ScreenshotFormatConfig
@@ -136,7 +136,7 @@ class ScrapeRequest(CamelModel):
136136
url: HttpUrl
137137
content_type: ApiFetchContentType | None = None
138138
fetch_config: FetchConfig | None = None
139-
formats: list[ScrapeFormatEntry] = Field(default_factory=lambda: [MarkdownFormatConfig()])
139+
formats: list[FormatConfig] = Field(default_factory=lambda: [MarkdownFormatConfig()])
140140

141141
@model_validator(mode="after")
142142
def validate_unique_formats(self):
@@ -184,7 +184,7 @@ def validate_schema_requires_prompt(self):
184184
class MonitorCreateRequest(CamelModel):
185185
url: HttpUrl
186186
name: Annotated[str, Field(max_length=200)] | None = None
187-
formats: list[ScrapeFormatEntry] = Field(default_factory=lambda: [MarkdownFormatConfig()])
187+
formats: list[FormatConfig] = Field(default_factory=lambda: [MarkdownFormatConfig()])
188188
webhook_url: HttpUrl | None = None
189189
interval: Annotated[str, Field(min_length=1, max_length=100)]
190190
fetch_config: FetchConfig | None = None
@@ -199,7 +199,7 @@ def validate_unique_formats(self):
199199

200200
class MonitorUpdateRequest(CamelModel):
201201
name: Annotated[str, Field(max_length=200)] | None = None
202-
formats: list[ScrapeFormatEntry] | None = None
202+
formats: list[FormatConfig] | None = None
203203
webhook_url: HttpUrl | None = None
204204
interval: Annotated[str, Field(min_length=1, max_length=100)] | None = None
205205
fetch_config: FetchConfig | None = None
@@ -215,7 +215,7 @@ def validate_unique_formats(self):
215215

216216
class CrawlRequest(CamelModel):
217217
url: HttpUrl
218-
formats: list[ScrapeFormatEntry] = Field(default_factory=lambda: [MarkdownFormatConfig()])
218+
formats: list[FormatConfig] = Field(default_factory=lambda: [MarkdownFormatConfig()])
219219
max_depth: int = Field(default=2, ge=0)
220220
max_pages: int = Field(default=50, ge=1, le=1000)
221221
max_links_per_page: int = Field(default=10, ge=1)

0 commit comments

Comments
 (0)