Skip to content

Commit 809f453

Browse files
authored
build: Bump ty to v0.0.17 and fix type issues (#1748)
1 parent 1d3fb4f commit 809f453

File tree

4 files changed

+44
-43
lines changed

4 files changed

+44
-43
lines changed

src/crawlee/storage_clients/_redis/_key_value_store_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ async def iterate_keys(
223223
raise TypeError('The items data was received in an incorrect format.')
224224

225225
# Get all keys, sorted alphabetically
226-
keys = sorted(items_data.keys()) # ty: ignore[invalid-argument-type]
226+
keys = sorted(items_data.keys())
227227

228228
# Apply exclusive_start_key filter if provided
229229
if exclusive_start_key is not None:

tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class TestInput:
116116
expected_pw_count=0,
117117
expected_static_count=2,
118118
# Lack of ty support, see https://github.com/astral-sh/ty/issues/2348.
119-
rendering_types=cycle(['static']), # ty: ignore[invalid-argument-type]
119+
rendering_types=cycle(['static']),
120120
detection_probability_recommendation=cycle([0]),
121121
),
122122
id='Static only',
@@ -125,7 +125,7 @@ class TestInput:
125125
TestInput(
126126
expected_pw_count=2,
127127
expected_static_count=0,
128-
rendering_types=cycle(['client only']), # ty: ignore[invalid-argument-type]
128+
rendering_types=cycle(['client only']),
129129
detection_probability_recommendation=cycle([0]),
130130
),
131131
id='Client only',
@@ -134,7 +134,7 @@ class TestInput:
134134
TestInput(
135135
expected_pw_count=1,
136136
expected_static_count=1,
137-
rendering_types=cycle(['static', 'client only']), # ty: ignore[invalid-argument-type]
137+
rendering_types=cycle(['static', 'client only']),
138138
detection_probability_recommendation=cycle([0]),
139139
),
140140
id='Mixed',
@@ -143,7 +143,7 @@ class TestInput:
143143
TestInput(
144144
expected_pw_count=2,
145145
expected_static_count=2,
146-
rendering_types=cycle(['static', 'client only']), # ty: ignore[invalid-argument-type]
146+
rendering_types=cycle(['static', 'client only']),
147147
detection_probability_recommendation=cycle([1]),
148148
),
149149
id='Enforced rendering type detection',
@@ -207,7 +207,7 @@ async def pre_nav_hook(context: AdaptivePlaywrightPreNavCrawlingContext) -> None
207207
async def test_adaptive_crawling_parsel(test_urls: list[str]) -> None:
208208
"""Top level test for parsel. Only one argument combination. (The rest of code is tested with bs variant.)"""
209209
predictor = _SimpleRenderingTypePredictor(
210-
rendering_types=cycle(['static', 'client only']), # ty: ignore[invalid-argument-type]
210+
rendering_types=cycle(['static', 'client only']),
211211
detection_probability_recommendation=cycle([0]),
212212
)
213213

@@ -693,7 +693,7 @@ async def test_adaptive_context_helpers_on_changed_selector(test_urls: list[str]
693693
dynamically changed text instead of the original static text.
694694
"""
695695
browser_only_predictor_no_detection = _SimpleRenderingTypePredictor(
696-
rendering_types=cycle(['client only']), # ty: ignore[invalid-argument-type]
696+
rendering_types=cycle(['client only']),
697697
detection_probability_recommendation=cycle([0]),
698698
)
699699
expected_h3_tag = f'<h3>{_H3_CHANGED_TEXT}</h3>'
@@ -719,7 +719,7 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None:
719719
async def test_adaptive_context_query_non_existing_element(test_urls: list[str]) -> None:
720720
"""Test that querying non-existing selector returns `None`"""
721721
browser_only_predictor_no_detection = _SimpleRenderingTypePredictor(
722-
rendering_types=cycle(['client only']), # ty: ignore[invalid-argument-type]
722+
rendering_types=cycle(['client only']),
723723
detection_probability_recommendation=cycle([0]),
724724
)
725725

@@ -746,8 +746,7 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None:
746746
TestInput(
747747
expected_pw_count=0,
748748
expected_static_count=2,
749-
# Lack of ty support, see https://github.com/astral-sh/ty/issues/2348.
750-
rendering_types=cycle(['static']), # ty: ignore[invalid-argument-type]
749+
rendering_types=cycle(['static']),
751750
detection_probability_recommendation=cycle([0]),
752751
),
753752
id='Static only',
@@ -756,7 +755,7 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None:
756755
TestInput(
757756
expected_pw_count=2,
758757
expected_static_count=0,
759-
rendering_types=cycle(['client only']), # ty: ignore[invalid-argument-type]
758+
rendering_types=cycle(['client only']),
760759
detection_probability_recommendation=cycle([0]),
761760
),
762761
id='Client only',
@@ -765,7 +764,7 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None:
765764
TestInput(
766765
expected_pw_count=2,
767766
expected_static_count=2,
768-
rendering_types=cycle(['static', 'client only']), # ty: ignore[invalid-argument-type]
767+
rendering_types=cycle(['static', 'client only']),
769768
detection_probability_recommendation=cycle([1]),
770769
),
771770
id='Enforced rendering type detection',

tests/unit/crawlers/_basic/test_basic_crawler.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,17 +1093,19 @@ async def handler(context: BasicCrawlingContext) -> None:
10931093
else:
10941094
assert final_statistics.msg == 'Final request statistics:'
10951095

1096-
# ignore[attr-defined] since `extra` parameters are not defined for `LogRecord`
1097-
assert final_statistics.requests_finished == 4
1098-
assert final_statistics.requests_failed == 33
1099-
assert final_statistics.retry_histogram == [1, 4, 8]
1100-
assert final_statistics.request_avg_failed_duration == 99.0
1101-
assert final_statistics.request_avg_finished_duration == 0.483
1102-
assert final_statistics.requests_finished_per_minute == 0.33
1103-
assert final_statistics.requests_failed_per_minute == 0.1
1104-
assert final_statistics.request_total_duration == 720.0
1105-
assert final_statistics.requests_total == 37
1106-
assert final_statistics.crawler_runtime == 300.0
1096+
# `extra` parameters are not defined on `LogRecord`, so we cast to `Any` to access them.
1097+
record = cast('Any', final_statistics)
1098+
1099+
assert record.requests_finished == 4
1100+
assert record.requests_failed == 33
1101+
assert record.retry_histogram == [1, 4, 8]
1102+
assert record.request_avg_failed_duration == 99.0
1103+
assert record.request_avg_finished_duration == 0.483
1104+
assert record.requests_finished_per_minute == 0.33
1105+
assert record.requests_failed_per_minute == 0.1
1106+
assert record.request_total_duration == 720.0
1107+
assert record.requests_total == 37
1108+
assert record.crawler_runtime == 300.0
11071109

11081110

11091111
async def test_crawler_manual_stop() -> None:

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)