From 0d91e129014369534a9a37078f90c8f81f8236a6 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Tue, 19 May 2026 16:43:35 +0200 Subject: [PATCH 1/2] fix: Use DeprecationWarning for deprecated methods and arguments (#802) Replace `logger.warning(...)` calls with `warnings.warn(..., DeprecationWarning)` for deprecated request queue client arguments (`max_unprocessed_requests_retries`, `min_delay_between_unprocessed_requests_retries`), and also emit a `DeprecationWarning` when `exclusive_start_id` is passed to `list_requests`. Using the `warnings` machinery makes deprecations discoverable by tooling and matches Python conventions. --- .../clients/resource_clients/request_queue.py | 56 ++++++++++++++----- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/src/apify_client/clients/resource_clients/request_queue.py b/src/apify_client/clients/resource_clients/request_queue.py index c3ee1bf6..1102fbea 100644 --- a/src/apify_client/clients/resource_clients/request_queue.py +++ b/src/apify_client/clients/resource_clients/request_queue.py @@ -1,8 +1,8 @@ from __future__ import annotations import asyncio -import logging import math +import warnings from collections.abc import Iterable from queue import Queue from typing import TYPE_CHECKING, Any, TypedDict @@ -23,8 +23,6 @@ from apify_shared.consts import StorageGeneralAccess -logger = logging.getLogger(__name__) - _RQ_MAX_REQUESTS_PER_BATCH = 25 _MAX_PAYLOAD_SIZE_BYTES = 9 * 1024 * 1024 # 9 MB _SAFETY_BUFFER_PERCENT = 0.01 / 100 # 0.01% @@ -304,16 +302,25 @@ def batch_add_requests( max_parallel: Specifies the maximum number of parallel tasks for API calls. This is only applicable to the async client. For the sync client, this value must be set to 1, as parallel execution is not supported. - max_unprocessed_requests_retries: Deprecated argument. Will be removed in next major release. - min_delay_between_unprocessed_requests_retries: Deprecated argument. Will be removed in next major release. + max_unprocessed_requests_retries: Deprecated argument. Will be removed in v3. + min_delay_between_unprocessed_requests_retries: Deprecated argument. Will be removed in v3. Returns: Result containing lists of processed and unprocessed requests. """ if max_unprocessed_requests_retries: - logger.warning('`max_unprocessed_requests_retries` is deprecated and not used anymore.') + warnings.warn( + 'The `max_unprocessed_requests_retries` argument is deprecated and will be removed in v3.', + DeprecationWarning, + stacklevel=2, + ) if min_delay_between_unprocessed_requests_retries: - logger.warning('`min_delay_between_unprocessed_requests_retries` is deprecated and not used anymore.') + warnings.warn( + 'The `min_delay_between_unprocessed_requests_retries` argument is deprecated and will be removed ' + 'in v3.', + DeprecationWarning, + stacklevel=2, + ) if max_parallel != 1: raise NotImplementedError('max_parallel is only supported in async client') @@ -393,8 +400,15 @@ def list_requests( Args: limit: How many requests to retrieve. - exclusive_start_id: All requests up to this one (including) are skipped from the result. + exclusive_start_id: Deprecated argument. Will be removed in v3. """ + if exclusive_start_id is not None: + warnings.warn( + 'The `exclusive_start_id` argument is deprecated and will be removed in v3.', + DeprecationWarning, + stacklevel=2, + ) + request_params = self._params(limit=limit, exclusiveStartId=exclusive_start_id, clientKey=self.client_key) response = self.http_client.call( @@ -731,16 +745,25 @@ async def batch_add_requests( max_parallel: Specifies the maximum number of parallel tasks for API calls. This is only applicable to the async client. For the sync client, this value must be set to 1, as parallel execution is not supported. - max_unprocessed_requests_retries: Deprecated argument. Will be removed in next major release. - min_delay_between_unprocessed_requests_retries: Deprecated argument. Will be removed in next major release. + max_unprocessed_requests_retries: Deprecated argument. Will be removed in v3. + min_delay_between_unprocessed_requests_retries: Deprecated argument. Will be removed in v3. Returns: Result containing lists of processed and unprocessed requests. """ if max_unprocessed_requests_retries: - logger.warning('`max_unprocessed_requests_retries` is deprecated and not used anymore.') + warnings.warn( + 'The `max_unprocessed_requests_retries` argument is deprecated and will be removed in v3.', + DeprecationWarning, + stacklevel=2, + ) if min_delay_between_unprocessed_requests_retries: - logger.warning('`min_delay_between_unprocessed_requests_retries` is deprecated and not used anymore.') + warnings.warn( + 'The `min_delay_between_unprocessed_requests_retries` argument is deprecated and will be removed ' + 'in v3.', + DeprecationWarning, + stacklevel=2, + ) tasks = set[asyncio.Task]() queue: asyncio.Queue[Iterable[dict]] = asyncio.Queue() @@ -821,8 +844,15 @@ async def list_requests( Args: limit: How many requests to retrieve. - exclusive_start_id: All requests up to this one (including) are skipped from the result. + exclusive_start_id: Deprecated argument. Will be removed in v3. """ + if exclusive_start_id is not None: + warnings.warn( + 'The `exclusive_start_id` argument is deprecated and will be removed in v3.', + DeprecationWarning, + stacklevel=2, + ) + request_params = self._params(limit=limit, exclusiveStartId=exclusive_start_id, clientKey=self.client_key) response = await self.http_client.call( From 42f6f010d492089777046bfc326d2745ca4f261f Mon Sep 17 00:00:00 2001 From: Apify Service Account <64261774+apify-service-account@users.noreply.github.com> Date: Wed, 20 May 2026 11:43:03 +0200 Subject: [PATCH 2/2] chore(release): Update changelog and package version [skip ci] --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- uv.lock | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c10a54a..dcd4ac97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## [2.5.1](https://github.com/apify/apify-client-python/releases/tag/v2.5.1) (2026-05-20) + +### 🐛 Bug Fixes + +- Use DeprecationWarning for deprecated methods and arguments (#802) ([0d91e12](https://github.com/apify/apify-client-python/commit/0d91e129014369534a9a37078f90c8f81f8236a6)) + + ## [2.5.0](https://github.com/apify/apify-client-python/releases/tag/v2.5.0) (2026-02-18) ### 🚀 Features diff --git a/pyproject.toml b/pyproject.toml index a9bff020..4f7e6f08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "apify_client" -version = "2.5.0" +version = "2.5.1" description = "Apify API client for Python" authors = [{ name = "Apify Technologies s.r.o.", email = "support@apify.com" }] license = { file = "LICENSE" } diff --git a/uv.lock b/uv.lock index f77eaf61..1deb1c83 100644 --- a/uv.lock +++ b/uv.lock @@ -4,7 +4,7 @@ requires-python = ">=3.10" [[package]] name = "apify-client" -version = "2.5.0" +version = "2.5.1" source = { editable = "." } dependencies = [ { name = "apify-shared" }, @@ -539,6 +539,7 @@ dependencies = [ { name = "griffecli" }, { name = "griffelib" }, ] +sdist = { url = "https://files.pythonhosted.org/packages/04/56/28a0accac339c164b52a92c6cfc45a903acc0c174caa5c1713803467b533/griffe-2.0.0.tar.gz", hash = "sha256:c68979cd8395422083a51ea7cf02f9c119d889646d99b7b656ee43725de1b80f", size = 293906, upload-time = "2026-03-23T21:06:53.402Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/8b/94/ee21d41e7eb4f823b94603b9d40f86d3c7fde80eacc2c3c71845476dddaa/griffe-2.0.0-py3-none-any.whl", hash = "sha256:5418081135a391c3e6e757a7f3f156f1a1a746cc7b4023868ff7d5e2f9a980aa", size = 5214, upload-time = "2026-02-09T19:09:44.105Z" }, ] @@ -551,6 +552,7 @@ dependencies = [ { name = "colorama" }, { name = "griffelib" }, ] +sdist = { url = "https://files.pythonhosted.org/packages/a4/f8/2e129fd4a86e52e58eefe664de05e7d502decf766e7316cc9e70fdec3e18/griffecli-2.0.0.tar.gz", hash = "sha256:312fa5ebb4ce6afc786356e2d0ce85b06c1c20d45abc42d74f0cda65e159f6ef", size = 56213, upload-time = "2026-03-23T21:06:54.8Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/e6/ed/d93f7a447bbf7a935d8868e9617cbe1cadf9ee9ee6bd275d3040fbf93d60/griffecli-2.0.0-py3-none-any.whl", hash = "sha256:9f7cd9ee9b21d55e91689358978d2385ae65c22f307a63fb3269acf3f21e643d", size = 9345, upload-time = "2026-02-09T19:09:42.554Z" }, ] @@ -559,6 +561,7 @@ wheels = [ name = "griffelib" version = "2.0.0" source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ad/06/eccbd311c9e2b3ca45dbc063b93134c57a1ccc7607c5e545264ad092c4a9/griffelib-2.0.0.tar.gz", hash = "sha256:e504d637a089f5cab9b5daf18f7645970509bf4f53eda8d79ed71cce8bd97934", size = 166312, upload-time = "2026-03-23T21:06:55.954Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/4d/51/c936033e16d12b627ea334aaaaf42229c37620d0f15593456ab69ab48161/griffelib-2.0.0-py3-none-any.whl", hash = "sha256:01284878c966508b6d6f1dbff9b6fa607bc062d8261c5c7253cb285b06422a7f", size = 142004, upload-time = "2026-02-09T19:09:40.561Z" }, ]