diff --git a/src/apify_client/clients/resource_clients/dataset.py b/src/apify_client/clients/resource_clients/dataset.py index e718ffb4..ccb82cfb 100644 --- a/src/apify_client/clients/resource_clients/dataset.py +++ b/src/apify_client/clients/resource_clients/dataset.py @@ -270,15 +270,11 @@ def download_items( Returns: bytes: The dataset items as raw bytes """ - # We need to override and then restore the warnings filter so that the warning gets printed out, - # Otherwise it would be silently swallowed - with warnings.catch_warnings(): - warnings.simplefilter('always') - warnings.warn( - '`DatasetClient.download_items()` is deprecated, use `DatasetClient.get_items_as_bytes()` instead.', - DeprecationWarning, - stacklevel=2, - ) + warnings.warn( + '`DatasetClient.download_items()` is deprecated, use `DatasetClient.get_items_as_bytes()` instead.', + DeprecationWarning, + stacklevel=2, + ) return self.get_items_as_bytes( item_format=item_format, diff --git a/src/apify_client/clients/resource_clients/key_value_store.py b/src/apify_client/clients/resource_clients/key_value_store.py index 555c87eb..eb52dead 100644 --- a/src/apify_client/clients/resource_clients/key_value_store.py +++ b/src/apify_client/clients/resource_clients/key_value_store.py @@ -95,28 +95,19 @@ def get_record(self, key: str, *, as_bytes: bool = False, as_file: bool = False) raise ValueError('You cannot have both as_bytes and as_file set.') if as_bytes: - # We need to override and then restore the warnings filter so that the warning gets printed out, - # Otherwise it would be silently swallowed - with warnings.catch_warnings(): - warnings.simplefilter('always') - warnings.warn( - '`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, use `KeyValueStoreClient.get_record_as_bytes()` instead.', # noqa: E501 - DeprecationWarning, - stacklevel=2, - ) - + warnings.warn( + '`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, use `KeyValueStoreClient.get_record_as_bytes()` instead.', # noqa: E501 + DeprecationWarning, + stacklevel=2, + ) return self.get_record_as_bytes(key) if as_file: - # We need to override and then restore the warnings filter so that the warning gets printed out, - # Otherwise it would be silently swallowed - with warnings.catch_warnings(): - warnings.simplefilter('always') - warnings.warn( - '`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, use `KeyValueStoreClient.stream_record()` instead.', - DeprecationWarning, - stacklevel=2, - ) + warnings.warn( + '`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, use `KeyValueStoreClient.stream_record()` instead.', + DeprecationWarning, + stacklevel=2, + ) return self.stream_record(key) # type: ignore response = self.http_client.call(