Skip to content

Commit 0515df5

Browse files
committed
freeze core Request fields
1 parent 60e39a3 commit 0515df5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/crawlee/_request.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class Request(BaseModel):
166166

167167
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
168168

169-
unique_key: Annotated[str, Field(alias='uniqueKey')]
169+
unique_key: Annotated[str, Field(alias='uniqueKey', frozen=True)]
170170
"""A unique key identifying the request. Two requests with the same `unique_key` are considered as pointing
171171
to the same URL.
172172
@@ -178,17 +178,18 @@ class Request(BaseModel):
178178
and specify which URLs shall be considered equal.
179179
"""
180180

181-
url: Annotated[str, BeforeValidator(validate_http_url), Field()]
181+
url: Annotated[str, BeforeValidator(validate_http_url), Field(frozen=True)]
182182
"""The URL of the web page to crawl. Must be a valid HTTP or HTTPS URL, and may include query parameters
183183
and fragments."""
184184

185-
method: HttpMethod = 'GET'
185+
method: Annotated[HttpMethod, Field(frozen=True)] = 'GET'
186186
"""HTTP request method."""
187187

188188
payload: Annotated[
189189
HttpPayload | None,
190190
BeforeValidator(lambda v: v.encode() if isinstance(v, str) else v),
191191
PlainSerializer(lambda v: v.decode() if isinstance(v, bytes) else v),
192+
Field(frozen=True),
192193
] = None
193194
"""HTTP request payload."""
194195

0 commit comments

Comments
 (0)