Skip to content

Commit 69cc855

Browse files
authored
build: Bump ty to v0.0.25 and fix type issues (#1811)
1 parent f539d3f commit 69cc855

File tree

8 files changed

+35
-35
lines changed

8 files changed

+35
-35
lines changed

src/crawlee/otel/crawler_instrumentor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ def _init_wrapper(wrapped: Any, _: Any, args: Any, kwargs: Any) -> None:
6969

7070
async def middleware_wrapper(wrapped: Any, instance: _Middleware, args: Any, kwargs: Any) -> Any:
7171
with self._tracer.start_as_current_span(
72-
name=f'{instance.generator.__name__}, {wrapped.__name__}', # type:ignore[attr-defined] # valid in our context
72+
name=f'{instance.generator.__name__}, {wrapped.__name__}', # ty:ignore[unresolved-attribute] # valid in our context
7373
attributes={
7474
URL_FULL: instance.input_context.request.url,
75-
CODE_FUNCTION_NAME: instance.generator.__qualname__, # type:ignore[attr-defined] # valid in our context
75+
CODE_FUNCTION_NAME: instance.generator.__qualname__, # ty:ignore[unresolved-attribute] # valid in our context
7676
},
7777
):
7878
return await wrapped(*args, **kwargs)

src/crawlee/storage_clients/_base/_dataset_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ async def iterate_items(
8888
The backend method for the `Dataset.iterate_items` call.
8989
"""
9090
# This syntax is to make type checker properly work with abstract AsyncIterator.
91-
# https://mypy.readthedocs.io/en/stable/more_types.html#asynchronous-iterators
9291
raise NotImplementedError
9392
if False:
94-
yield 0
93+
yield {}

src/crawlee/storage_clients/_base/_key_value_store_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
from abc import ABC, abstractmethod
44
from typing import TYPE_CHECKING, Any
55

6+
from crawlee.storage_clients.models import KeyValueStoreRecordMetadata
7+
68
if TYPE_CHECKING:
79
from collections.abc import AsyncIterator
810

9-
from crawlee.storage_clients.models import KeyValueStoreMetadata, KeyValueStoreRecord, KeyValueStoreRecordMetadata
11+
from crawlee.storage_clients.models import KeyValueStoreMetadata, KeyValueStoreRecord
1012

1113

1214
class KeyValueStoreClient(ABC):
@@ -73,10 +75,9 @@ async def iterate_keys(
7375
The backend method for the `KeyValueStore.iterate_keys` call.
7476
"""
7577
# This syntax is to make type checker properly work with abstract AsyncIterator.
76-
# https://mypy.readthedocs.io/en/stable/more_types.html#asynchronous-iterators
7778
raise NotImplementedError
7879
if False:
79-
yield 0
80+
yield KeyValueStoreRecordMetadata()
8081

8182
@abstractmethod
8283
async def get_public_url(self, *, key: str) -> str:

src/crawlee/storages/_storage_instance_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def open_storage_instance(
167167

168168
metadata = await client.get_metadata()
169169

170-
instance = cls(client, metadata.id, metadata.name) # type: ignore[call-arg]
170+
instance = cls(client, metadata.id, metadata.name) # ty: ignore[too-many-positional-arguments]
171171
instance_name = getattr(instance, 'name', None)
172172

173173
# Cache the instance.

tests/unit/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def _prepare_test_env() -> None:
7474

7575
# Reset global class variables to ensure test isolation.
7676
KeyValueStore._autosaved_values = {}
77-
Statistics._Statistics__next_id = 0 # type:ignore[attr-defined] # Mangled attribute
78-
BasicCrawler._BasicCrawler__next_id = 0 # type:ignore[attr-defined] # Mangled attribute
77+
Statistics._Statistics__next_id = 0 # ty:ignore[unresolved-attribute] # Mangled attribute
78+
BasicCrawler._BasicCrawler__next_id = 0 # ty:ignore[unresolved-attribute] # Mangled attribute
7979

8080
return _prepare_test_env
8181

tests/unit/crawlers/_basic/test_basic_crawler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ async def test_crawler_multiple_stops_in_parallel() -> None:
11681168
# Set concurrency to 2 to ensure two urls are being visited in parallel.
11691169
crawler = BasicCrawler(concurrency_settings=ConcurrencySettings(desired_concurrency=2, max_concurrency=2))
11701170

1171-
both_handlers_started = asyncio.Barrier(2) # type:ignore[attr-defined] # Test is skipped in older Python versions.
1171+
both_handlers_started = asyncio.Barrier(2) # ty:ignore[unresolved-attribute] # Test is skipped in older Python versions.
11721172
only_one_handler_at_a_time = asyncio.Semaphore(1)
11731173

11741174
@crawler.router.default_handler
@@ -1352,7 +1352,7 @@ async def test_context_use_state_race_condition_in_handlers(key_value_store: Key
13521352
Result should be incremented by 2.
13531353
Method `use_state` must be implemented in a way that prevents race conditions in such scenario."""
13541354
# Test is skipped in older Python versions.
1355-
from asyncio import Barrier # type:ignore[attr-defined] # noqa: PLC0415
1355+
from asyncio import Barrier # ty:ignore[unresolved-import] # noqa: PLC0415
13561356

13571357
crawler = BasicCrawler()
13581358
store = await crawler.get_key_value_store()
@@ -1393,7 +1393,7 @@ async def test_timeout_in_handler(sleep_type: str) -> None:
13931393
Crawler should attempt to retry it.
13941394
This test creates situation where the request handler times out twice, on third retry it does not time out."""
13951395
# Test is skipped in older Python versions.
1396-
from asyncio import timeout # type:ignore[attr-defined] # noqa: PLC0415
1396+
from asyncio import timeout # ty:ignore[unresolved-import] # noqa: PLC0415
13971397

13981398
non_realtime_system_coefficient = 10
13991399
handler_timeout = timedelta(seconds=1)

tests/unit/storages/test_storage_instance_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async def test_preexisting_unnamed_storage_open_by_id(storage_type: type[Storage
136136
@pytest.mark.skipif(sys.version_info[:3] < (3, 11), reason='asyncio.Barrier was introduced in Python 3.11.')
137137
async def test_concurrent_open_datasets() -> None:
138138
"""Test that concurrent open datasets with the same name return the same instance."""
139-
from asyncio import Barrier # type:ignore[attr-defined] # noqa: PLC0415
139+
from asyncio import Barrier # ty:ignore[unresolved-import] # noqa: PLC0415
140140

141141
barrier = Barrier(2)
142142

@@ -161,7 +161,7 @@ async def push_data(data: dict) -> None:
161161
@pytest.mark.skipif(sys.version_info[:3] < (3, 11), reason='asyncio.Barrier was introduced in Python 3.11.')
162162
async def test_concurrent_open_datasets_with_same_name_and_alias() -> None:
163163
"""Test that concurrent open requests for the same storage return the same instance."""
164-
from asyncio import Barrier # type:ignore[attr-defined] # noqa: PLC0415
164+
from asyncio import Barrier # ty:ignore[unresolved-import] # noqa: PLC0415
165165

166166
valid_kwargs: dict[str, str | None] = {}
167167

uv.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)