Skip to content

Commit f660cea

Browse files
committed
resolve type issues
1 parent ab3b271 commit f660cea

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/apify/_charging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ async def __aenter__(self) -> None:
158158
if self._configuration.test_pay_per_event:
159159
self._pricing_model = 'PAY_PER_EVENT'
160160
else:
161-
self._pricing_model = pricing_info.pricing_model if pricing_info else None
161+
self._pricing_model = pricing_info.pricing_model if pricing_info is not None else None
162162

163163
# Load per-event pricing information
164-
if pricing_info and pricing_info.pricing_model == 'PAY_PER_EVENT':
165-
for event_name, event_pricing in pricing_info.pricing_per_event.actor_charge_events.items(): # ty:ignore[possibly-missing-attribute]
164+
if pricing_info is not None and isinstance(pricing_info, PayPerEventActorPricingInfo):
165+
for event_name, event_pricing in pricing_info.pricing_per_event.actor_charge_events.items():
166166
self._pricing_info[event_name] = PricingInfoItem(
167167
price=event_pricing.event_price_usd,
168168
title=event_pricing.event_title,

tests/integration/test_request_queue.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ._utils import generate_unique_resource_name
1616
from apify import Actor, Request
1717
from apify.storage_clients import ApifyStorageClient
18+
from apify.storage_clients._apify import ApifyRequestQueueClient
1819
from apify.storage_clients._apify._utils import unique_key_to_request_id
1920
from apify.storages import RequestQueue
2021

@@ -683,7 +684,7 @@ async def test_request_deduplication_edge_cases(
683684
"""Test edge cases in request deduplication."""
684685
rq_access_mode = request.node.callspec.params.get('request_queue_apify')
685686
if rq_access_mode == 'shared':
686-
pytest.skip('Test is flaky, see https://github.com/apify/apify-sdk-python/issues/786')
687+
pytest.skip(reason='Test is flaky, see https://github.com/apify/apify-sdk-python/issues/786') # ty: ignore[invalid-argument-type, parameter-already-assigned]
687688

688689
rq = request_queue_apify
689690
Actor.log.info('Request queue opened')
@@ -1218,17 +1219,25 @@ async def test_request_queue_api_fail_when_marking_as_handled(
12181219
# Fetch request
12191220
await rq.add_request(request)
12201221
assert request == await rq.fetch_next_request()
1222+
assert isinstance(rq._client, ApifyRequestQueueClient)
12211223

12221224
# Mark as handled, but simulate API failure.
12231225
with mock.patch.object(
1224-
rq._client._api_client, 'update_request', side_effect=Exception('Simulated API failure')
1226+
rq._client._api_client,
1227+
'update_request',
1228+
side_effect=Exception('Simulated API failure'),
12251229
):
12261230
await rq.mark_request_as_handled(request)
1227-
assert not (await rq.get_request(request.unique_key)).was_already_handled
1231+
1232+
request = await rq.get_request(request.unique_key)
1233+
assert request is not None
1234+
assert not request.was_already_handled
12281235

12291236
# RQ with `request_queue_access="single"` knows, that the local information is reliable, so it knows it
12301237
# handled this request already despite the platform not being aware of it.
1231-
assert not await rq.fetch_next_request()
1238+
next_request = await rq.fetch_next_request()
1239+
assert next_request is None
1240+
12321241
assert await rq.is_finished()
12331242
assert await rq.is_empty()
12341243

0 commit comments

Comments
 (0)