File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -238,9 +238,19 @@ def push_scope( # noqa: F811
238
238
:returns: If no `callback` is provided, a context manager that should
239
239
be used to pop the scope again.
240
240
"""
241
+ warnings .warn (
242
+ "sentry_sdk.push_scope is deprecated and will be removed in the next major version. "
243
+ "Please consult our migration guide to learn how to migrate to the new API: "
244
+ "https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-pushing" ,
245
+ DeprecationWarning ,
246
+ stacklevel = 2 ,
247
+ )
248
+
241
249
if callback is not None :
242
- with push_scope () as scope :
243
- callback (scope )
250
+ with warnings .catch_warnings ():
251
+ warnings .simplefilter ("ignore" , DeprecationWarning )
252
+ with push_scope () as scope :
253
+ callback (scope )
244
254
return None
245
255
246
256
return _ScopeManager ()
Original file line number Diff line number Diff line change 12
12
start_transaction ,
13
13
set_tags ,
14
14
configure_scope ,
15
+ push_scope ,
15
16
)
16
17
17
18
from sentry_sdk .client import Client , NonRecordingClient
@@ -186,3 +187,9 @@ def test_configure_scope_deprecation():
186
187
with pytest .warns (DeprecationWarning ):
187
188
with configure_scope ():
188
189
...
190
+
191
+
192
+ def test_push_scope_deprecation ():
193
+ with pytest .warns (DeprecationWarning ):
194
+ with push_scope ():
195
+ ...
Original file line number Diff line number Diff line change @@ -295,7 +295,7 @@ def before_breadcrumb(crumb, hint):
295
295
add_breadcrumb (crumb = dict (foo = 42 ))
296
296
297
297
298
- def test_push_scope (sentry_init , capture_events ):
298
+ def test_push_scope (sentry_init , capture_events , suppress_deprecation_warnings ):
299
299
sentry_init ()
300
300
events = capture_events ()
301
301
@@ -312,7 +312,9 @@ def test_push_scope(sentry_init, capture_events):
312
312
assert "exception" in event
313
313
314
314
315
- def test_push_scope_null_client (sentry_init , capture_events ):
315
+ def test_push_scope_null_client (
316
+ sentry_init , capture_events , suppress_deprecation_warnings
317
+ ):
316
318
"""
317
319
This test can be removed when we remove push_scope and the Hub from the SDK.
318
320
"""
You can’t perform that action at this time.
0 commit comments