|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import dataclasses |
4 | | -from collections.abc import Iterator, Mapping |
| 4 | +from collections.abc import Callable, Iterator, Mapping |
5 | 5 | from dataclasses import dataclass |
6 | 6 | from typing import ( |
7 | 7 | TYPE_CHECKING, |
8 | 8 | Annotated, |
9 | 9 | Any, |
10 | | - Callable, |
11 | 10 | Literal, |
12 | | - Optional, |
13 | 11 | Protocol, |
14 | 12 | TypedDict, |
15 | 13 | TypeVar, |
16 | | - Union, |
17 | 14 | cast, |
18 | 15 | overload, |
19 | 16 | ) |
|
28 | 25 | import re |
29 | 26 | from collections.abc import Callable, Coroutine, Sequence |
30 | 27 |
|
31 | | - from typing_extensions import NotRequired, Required, TypeAlias, Unpack |
| 28 | + from typing_extensions import NotRequired, Required, Unpack |
32 | 29 |
|
33 | 30 | from crawlee import Glob, Request |
34 | 31 | from crawlee._request import RequestOptions |
|
41 | 38 |
|
42 | 39 | # Workaround for https://github.com/pydantic/pydantic/issues/9445 |
43 | 40 | J = TypeVar('J', bound='JsonSerializable') |
44 | | - JsonSerializable: TypeAlias = Union[ |
45 | | - list[J], |
46 | | - dict[str, J], |
47 | | - str, |
48 | | - bool, |
49 | | - int, |
50 | | - float, |
51 | | - None, |
52 | | - ] |
| 41 | + JsonSerializable = list[J] | dict[str, J] | str | bool | int | float | None |
53 | 42 | else: |
54 | 43 | from pydantic import JsonValue as JsonSerializable |
55 | 44 |
|
56 | 45 | T = TypeVar('T') |
57 | 46 |
|
58 | | -HttpMethod: TypeAlias = Literal['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'] |
| 47 | +HttpMethod = Literal['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'] |
59 | 48 |
|
60 | | -HttpPayload: TypeAlias = bytes |
| 49 | +HttpPayload = bytes |
61 | 50 |
|
62 | | -RequestTransformAction: TypeAlias = Literal['skip', 'unchanged'] |
| 51 | +RequestTransformAction = Literal['skip', 'unchanged'] |
63 | 52 |
|
64 | | -EnqueueStrategy: TypeAlias = Literal['all', 'same-domain', 'same-hostname', 'same-origin'] |
| 53 | +EnqueueStrategy = Literal['all', 'same-domain', 'same-hostname', 'same-origin'] |
65 | 54 | """Enqueue strategy to be used for determining which links to extract and enqueue.""" |
66 | 55 |
|
67 | | -SkippedReason: TypeAlias = Literal['robots_txt'] |
| 56 | +SkippedReason = Literal['robots_txt'] |
68 | 57 |
|
69 | 58 |
|
70 | 59 | def _normalize_headers(headers: Mapping[str, str]) -> dict[str, str]: |
@@ -264,7 +253,7 @@ def __init__(self, *, key_value_store_getter: GetKeyValueStoreFunction) -> None: |
264 | 253 | self._key_value_store_getter = key_value_store_getter |
265 | 254 | self.add_requests_calls = list[AddRequestsKwargs]() |
266 | 255 | self.push_data_calls = list[PushDataFunctionCall]() |
267 | | - self.key_value_store_changes = dict[tuple[Optional[str], Optional[str]], KeyValueStoreChangeRecords]() |
| 256 | + self.key_value_store_changes = dict[tuple[str | None, str | None], KeyValueStoreChangeRecords]() |
268 | 257 |
|
269 | 258 | async def add_requests( |
270 | 259 | self, |
|
0 commit comments