Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rm warnings simplefilter always #135

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/apify_client/clients/resource_clients/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 10 additions & 19 deletions src/apify_client/clients/resource_clients/key_value_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down