diff --git a/src/apify/_charging.py b/src/apify/_charging.py index fa53b138..014f8b2b 100644 --- a/src/apify/_charging.py +++ b/src/apify/_charging.py @@ -226,7 +226,8 @@ def calculate_chargeable() -> dict[str, int | None]: # START OF CRITICAL SECTION - no awaits here # Determine the maximum amount of events that can be charged within the budget - charged_count = min(count, self.calculate_max_event_charge_count_within_limit(event_name) or count) + max_chargeable = self.calculate_max_event_charge_count_within_limit(event_name) + charged_count = min(count, max_chargeable if max_chargeable is not None else count) if charged_count == 0: return ChargeResult(