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
238238 :returns: If no `callback` is provided, a context manager that should
239239 be used to pop the scope again.
240240 """
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+
241249 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 )
244254 return None
245255
246256 return _ScopeManager ()
Original file line number Diff line number Diff line change 1212 start_transaction ,
1313 set_tags ,
1414 configure_scope ,
15+ push_scope ,
1516)
1617
1718from sentry_sdk .client import Client , NonRecordingClient
@@ -186,3 +187,9 @@ def test_configure_scope_deprecation():
186187 with pytest .warns (DeprecationWarning ):
187188 with configure_scope ():
188189 ...
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):
295295 add_breadcrumb (crumb = dict (foo = 42 ))
296296
297297
298- def test_push_scope (sentry_init , capture_events ):
298+ def test_push_scope (sentry_init , capture_events , suppress_deprecation_warnings ):
299299 sentry_init ()
300300 events = capture_events ()
301301
@@ -312,7 +312,9 @@ def test_push_scope(sentry_init, capture_events):
312312 assert "exception" in event
313313
314314
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+ ):
316318 """
317319 This test can be removed when we remove push_scope and the Hub from the SDK.
318320 """
You can’t perform that action at this time.
0 commit comments