Skip to content

Commit 36a02b6

Browse files
committed
chore: Bump ty to v0.0.14 and fix type issues (apify#1696)
1 parent 0cf612f commit 36a02b6

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

src/crawlee/crawlers/_adaptive_playwright/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def sklearn_model_validator(v: LogisticRegression | dict[str, Any]) -> LogisticR
2121
def sklearn_model_serializer(model: LogisticRegression) -> dict[str, Any]:
2222
if hasattr(model, 'coef_'):
2323
return {
24-
'coef': model.coef_.tolist(),
24+
'coef': np.asarray(model.coef_).tolist(),
2525
'intercept': model.intercept_.tolist(),
2626
'classes': model.classes_.tolist(),
2727
'n_iter': model.n_iter_.tolist() if hasattr(model, 'n_iter_') else [1000],

src/crawlee/crawlers/_playwright/_playwright_crawler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,7 @@ async def _get_cookies(self, page: Page) -> list[PlaywrightCookieParam]:
512512

513513
async def _update_cookies(self, page: Page, cookies: list[PlaywrightCookieParam]) -> None:
514514
"""Update the cookies in the page context."""
515-
# False positive ty error, see https://github.com/astral-sh/ty/issues/1493.
516-
await page.context.add_cookies([{**cookie} for cookie in cookies]) # ty: ignore[invalid-argument-type]
515+
await page.context.add_cookies([{**cookie} for cookie in cookies])
517516

518517
async def _find_txt_file_for_url(self, url: str) -> RobotsTxtFile:
519518
"""Find the robots.txt file for a given URL.

src/crawlee/storage_clients/_redis/_key_value_store_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ async def iterate_keys(
237237
# Yield metadata for each key
238238
for key in keys:
239239
record = items_data[key]
240+
if not isinstance(record, (str, bytes)):
241+
raise TypeError(f'Expected str or bytes, got {type(record)}')
240242
yield KeyValueStoreRecordMetadata.model_validate_json(record)
241243

242244
async with self._get_pipeline() as pipe:

tests/unit/storage_clients/_redis/test_redis_rq_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def test_request_records_persistence(rq_client: RedisRequestQueueClient) -
8080
assert request_queue_response is not None
8181
assert isinstance(request_queue_response, list)
8282
request_keys = request_queue_response[1]
83-
83+
assert isinstance(request_keys, list)
8484
assert len(request_keys) == 3
8585

8686
# Verify actual request file content
@@ -90,7 +90,7 @@ async def test_request_records_persistence(rq_client: RedisRequestQueueClient) -
9090
assert isinstance(requests_records_data, dict)
9191

9292
for key in request_keys:
93-
request_data = json.loads(requests_records_data[key])
93+
request_data = json.loads(requests_records_data[key]) # ty: ignore[invalid-argument-type]
9494
assert 'url' in request_data
9595
assert request_data['url'].startswith('https://example.com/')
9696

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)