Skip to content

Commit bacb5c5

Browse files
committed
fix types
1 parent f846386 commit bacb5c5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/apify/_charging.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import json
43
import math
54
from dataclasses import dataclass
65
from datetime import datetime, timezone
@@ -343,7 +342,7 @@ async def _fetch_pricing_info(self) -> _FetchedPricingInfoDict:
343342
if self._configuration.actor_pricing_info and self._configuration.charged_event_counts:
344343
return _FetchedPricingInfoDict(
345344
pricing_info=self._configuration.actor_pricing_info,
346-
charged_event_counts=json.loads(self._configuration.charged_event_counts),
345+
charged_event_counts=self._configuration.charged_event_counts,
347346
max_total_charge_usd=self._configuration.max_total_charge_usd or Decimal('inf'),
348347
)
349348

src/apify/_configuration.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,16 @@ class Configuration(CrawleeConfiguration):
427427
description='JSON string with prising info of the actor',
428428
discriminator='pricing_model',
429429
),
430-
BeforeValidator(lambda data: json.loads(data) if data else None),
430+
BeforeValidator(lambda data: json.loads(data) if isinstance(data, str) else data if data else None),
431431
] = None
432432

433433
charged_event_counts: Annotated[
434-
str | None,
434+
dict[str, int] | None,
435435
Field(
436436
alias='apify_charged_actor_event_counts',
437437
description='Counts of events that were charged for the actor',
438438
),
439+
BeforeValidator(lambda data: json.loads(data) if isinstance(data, str) else data if data else None),
439440
] = None
440441

441442
@model_validator(mode='after')

0 commit comments

Comments
 (0)