Skip to content

Commit e00cff9

Browse files
authored
Rm warnings simplefilter always (#135)
1 parent 98c77cd commit e00cff9

File tree

2 files changed

+15
-28
lines changed

2 files changed

+15
-28
lines changed

src/apify_client/clients/resource_clients/dataset.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,11 @@ def download_items(
270270
Returns:
271271
bytes: The dataset items as raw bytes
272272
"""
273-
# We need to override and then restore the warnings filter so that the warning gets printed out,
274-
# Otherwise it would be silently swallowed
275-
with warnings.catch_warnings():
276-
warnings.simplefilter('always')
277-
warnings.warn(
278-
'`DatasetClient.download_items()` is deprecated, use `DatasetClient.get_items_as_bytes()` instead.',
279-
DeprecationWarning,
280-
stacklevel=2,
281-
)
273+
warnings.warn(
274+
'`DatasetClient.download_items()` is deprecated, use `DatasetClient.get_items_as_bytes()` instead.',
275+
DeprecationWarning,
276+
stacklevel=2,
277+
)
282278

283279
return self.get_items_as_bytes(
284280
item_format=item_format,

src/apify_client/clients/resource_clients/key_value_store.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,19 @@ def get_record(self, key: str, *, as_bytes: bool = False, as_file: bool = False)
9595
raise ValueError('You cannot have both as_bytes and as_file set.')
9696

9797
if as_bytes:
98-
# We need to override and then restore the warnings filter so that the warning gets printed out,
99-
# Otherwise it would be silently swallowed
100-
with warnings.catch_warnings():
101-
warnings.simplefilter('always')
102-
warnings.warn(
103-
'`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, use `KeyValueStoreClient.get_record_as_bytes()` instead.', # noqa: E501
104-
DeprecationWarning,
105-
stacklevel=2,
106-
)
107-
98+
warnings.warn(
99+
'`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, use `KeyValueStoreClient.get_record_as_bytes()` instead.', # noqa: E501
100+
DeprecationWarning,
101+
stacklevel=2,
102+
)
108103
return self.get_record_as_bytes(key)
109104

110105
if as_file:
111-
# We need to override and then restore the warnings filter so that the warning gets printed out,
112-
# Otherwise it would be silently swallowed
113-
with warnings.catch_warnings():
114-
warnings.simplefilter('always')
115-
warnings.warn(
116-
'`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, use `KeyValueStoreClient.stream_record()` instead.',
117-
DeprecationWarning,
118-
stacklevel=2,
119-
)
106+
warnings.warn(
107+
'`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, use `KeyValueStoreClient.stream_record()` instead.',
108+
DeprecationWarning,
109+
stacklevel=2,
110+
)
120111
return self.stream_record(key) # type: ignore
121112

122113
response = self.http_client.call(

0 commit comments

Comments
 (0)