Skip to content

Commit 4ec6f6c

Browse files
authored
fix: Use Self type in the open() method of storage clients (#1462)
1 parent 0a823b4 commit 4ec6f6c

File tree

9 files changed

+18
-18
lines changed

9 files changed

+18
-18
lines changed

src/crawlee/storage_clients/_file_system/_dataset_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import TYPE_CHECKING, Any
1010

1111
from pydantic import ValidationError
12-
from typing_extensions import override
12+
from typing_extensions import Self, override
1313

1414
from crawlee._consts import METADATA_FILENAME
1515
from crawlee._utils.crypto import crypto_random_object_id
@@ -94,7 +94,7 @@ async def open(
9494
name: str | None,
9595
alias: str | None,
9696
configuration: Configuration,
97-
) -> FileSystemDatasetClient:
97+
) -> Self:
9898
"""Open or create a file system dataset client.
9999
100100
This method attempts to open an existing dataset from the file system. If a dataset with the specified ID

src/crawlee/storage_clients/_file_system/_key_value_store_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import TYPE_CHECKING, Any
1111

1212
from pydantic import ValidationError
13-
from typing_extensions import override
13+
from typing_extensions import Self, override
1414

1515
from crawlee._consts import METADATA_FILENAME
1616
from crawlee._utils.crypto import crypto_random_object_id
@@ -93,7 +93,7 @@ async def open(
9393
name: str | None,
9494
alias: str | None,
9595
configuration: Configuration,
96-
) -> FileSystemKeyValueStoreClient:
96+
) -> Self:
9797
"""Open or create a file system key-value store client.
9898
9999
This method attempts to open an existing key-value store from the file system. If a KVS with the specified

src/crawlee/storage_clients/_file_system/_request_queue_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from typing import TYPE_CHECKING
1212

1313
from pydantic import BaseModel, ValidationError
14-
from typing_extensions import override
14+
from typing_extensions import Self, override
1515

1616
from crawlee import Request
1717
from crawlee._consts import METADATA_FILENAME
@@ -144,7 +144,7 @@ async def open(
144144
name: str | None,
145145
alias: str | None,
146146
configuration: Configuration,
147-
) -> FileSystemRequestQueueClient:
147+
) -> Self:
148148
"""Open or create a file system request queue client.
149149
150150
This method attempts to open an existing request queue from the file system. If a queue with the specified

src/crawlee/storage_clients/_memory/_dataset_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from logging import getLogger
55
from typing import TYPE_CHECKING, Any
66

7-
from typing_extensions import override
7+
from typing_extensions import Self, override
88

99
from crawlee._utils.crypto import crypto_random_object_id
1010
from crawlee._utils.raise_if_too_many_kwargs import raise_if_too_many_kwargs
@@ -55,7 +55,7 @@ async def open(
5555
id: str | None,
5656
name: str | None,
5757
alias: str | None,
58-
) -> MemoryDatasetClient:
58+
) -> Self:
5959
"""Open or create a new memory dataset client.
6060
6161
This method creates a new in-memory dataset instance. Unlike persistent storage implementations, memory

src/crawlee/storage_clients/_memory/_key_value_store_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from datetime import datetime, timezone
55
from typing import TYPE_CHECKING, Any
66

7-
from typing_extensions import override
7+
from typing_extensions import Self, override
88

99
from crawlee._utils.crypto import crypto_random_object_id
1010
from crawlee._utils.file import infer_mime_type
@@ -53,7 +53,7 @@ async def open(
5353
id: str | None,
5454
name: str | None,
5555
alias: str | None,
56-
) -> MemoryKeyValueStoreClient:
56+
) -> Self:
5757
"""Open or create a new memory key-value store client.
5858
5959
This method creates a new in-memory key-value store instance. Unlike persistent storage implementations,

src/crawlee/storage_clients/_memory/_request_queue_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from logging import getLogger
77
from typing import TYPE_CHECKING
88

9-
from typing_extensions import override
9+
from typing_extensions import Self, override
1010

1111
from crawlee import Request
1212
from crawlee._utils.crypto import crypto_random_object_id
@@ -65,7 +65,7 @@ async def open(
6565
id: str | None,
6666
name: str | None,
6767
alias: str | None,
68-
) -> MemoryRequestQueueClient:
68+
) -> Self:
6969
"""Open or create a new memory request queue client.
7070
7171
This method creates a new in-memory request queue instance. Unlike persistent storage implementations,

src/crawlee/storage_clients/_sql/_dataset_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import TYPE_CHECKING, Any
55

66
from sqlalchemy import Select, insert, select
7-
from typing_extensions import override
7+
from typing_extensions import Self, override
88

99
from crawlee.storage_clients._base import DatasetClient
1010
from crawlee.storage_clients.models import DatasetItemsListPage, DatasetMetadata
@@ -78,7 +78,7 @@ async def open(
7878
name: str | None,
7979
alias: str | None,
8080
storage_client: SqlStorageClient,
81-
) -> SqlDatasetClient:
81+
) -> Self:
8282
"""Open an existing dataset or create a new one.
8383
8484
Args:

src/crawlee/storage_clients/_sql/_key_value_store_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, Any
66

77
from sqlalchemy import delete, select
8-
from typing_extensions import override
8+
from typing_extensions import Self, override
99

1010
from crawlee._utils.file import infer_mime_type
1111
from crawlee.storage_clients._base import KeyValueStoreClient
@@ -77,7 +77,7 @@ async def open(
7777
name: str | None,
7878
alias: str | None,
7979
storage_client: SqlStorageClient,
80-
) -> SqlKeyValueStoreClient:
80+
) -> Self:
8181
"""Open or create a SQL key-value store client.
8282
8383
This method attempts to open an existing key-value store from the SQL database. If a KVS with the specified

src/crawlee/storage_clients/_sql/_request_queue_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sqlalchemy import func, or_, select, update
1111
from sqlalchemy.exc import SQLAlchemyError
1212
from sqlalchemy.orm import load_only
13-
from typing_extensions import NotRequired, override
13+
from typing_extensions import NotRequired, Self, override
1414

1515
from crawlee import Request
1616
from crawlee._utils.crypto import crypto_random_object_id
@@ -119,7 +119,7 @@ async def open(
119119
name: str | None,
120120
alias: str | None,
121121
storage_client: SqlStorageClient,
122-
) -> SqlRequestQueueClient:
122+
) -> Self:
123123
"""Open an existing request queue or create a new one.
124124
125125
This method first tries to find an existing queue by ID or name.

0 commit comments

Comments
 (0)