[ 
https://issues.apache.org/jira/browse/BEAM-5932?focusedWorklogId=161786&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-161786
 ]

ASF GitHub Bot logged work on BEAM-5932:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Nov/18 23:42
            Start Date: 01/Nov/18 23:42
    Worklog Time Spent: 10m 
      Work Description: aaltay closed pull request #6907: [BEAM-5932] Re-enable 
Beam SDK deprecation warnings.
URL: https://github.com/apache/beam/pull/6907
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sdks/python/apache_beam/utils/annotations.py 
b/sdks/python/apache_beam/utils/annotations.py
index 12a6ecb1cb3..af44fac3335 100644
--- a/sdks/python/apache_beam/utils/annotations.py
+++ b/sdks/python/apache_beam/utils/annotations.py
@@ -88,6 +88,14 @@ def exp_multiply(arg1, arg2):
 from functools import wraps
 
 
+class BeamDeprecationWarning(DeprecationWarning):
+  """Beam-specific deprecation warnings."""
+
+
+# Don't ignore BeamDeprecationWarnings.
+warnings.simplefilter('once', BeamDeprecationWarning)
+
+
 def annotate(label, since, current, extra_message, custom_message=None):
   """Decorates an API with a deprecated or experimental annotation.
 
@@ -114,7 +122,7 @@ def _annotate(fnc):
     @wraps(fnc)
     def inner(*args, **kwargs):
       if label == 'deprecated':
-        warning_type = DeprecationWarning
+        warning_type = BeamDeprecationWarning
       else:
         warning_type = FutureWarning
       if custom_message is None:
diff --git a/sdks/python/apache_beam/utils/annotations_test.py 
b/sdks/python/apache_beam/utils/annotations_test.py
index 1493d365478..b9bd77470be 100644
--- a/sdks/python/apache_beam/utils/annotations_test.py
+++ b/sdks/python/apache_beam/utils/annotations_test.py
@@ -19,6 +19,7 @@
 import unittest
 import warnings
 
+from apache_beam.utils.annotations import BeamDeprecationWarning
 from apache_beam.utils.annotations import deprecated
 from apache_beam.utils.annotations import experimental
 
@@ -31,13 +32,10 @@ def test_deprecated_with_since_current_message(self):
       @deprecated(since='v.1', current='multiply', extra_message='Do this')
       def fnc_test_deprecated_with_since_current_message():
         return 'lol'
-      # Deprecation warnings are ignored by default, turn them on
-      # to enable testing.
-      warnings.simplefilter("always", DeprecationWarning)
       fnc_test_deprecated_with_since_current_message()
       self.check_annotation(
           warning=w,
-          warning_type=DeprecationWarning,
+          warning_type=BeamDeprecationWarning,
           obj_name='fnc_test_deprecated_with_since_current_message',
           annotation_type='deprecated',
           label_check_list=[('since', True),
@@ -49,12 +47,9 @@ def test_deprecated_with_since_current(self):
       @deprecated(since='v.1', current='multiply')
       def fnc_test_deprecated_with_since_current():
         return 'lol'
-      # Deprecation warnings are ignored by default, turn them on
-      # to enable testing.
-      warnings.simplefilter("once", DeprecationWarning)
       fnc_test_deprecated_with_since_current()
       self.check_annotation(warning=w,
-                            warning_type=DeprecationWarning,
+                            warning_type=BeamDeprecationWarning,
                             obj_name='fnc_test_deprecated_with_since_current',
                             annotation_type='deprecated',
                             label_check_list=[('since', True),
@@ -65,12 +60,9 @@ def test_deprecated_without_current(self):
       @deprecated(since='v.1')
       def fnc_test_deprecated_without_current():
         return 'lol'
-      # Deprecation warnings are ignored by default, turn them on
-      # to enable testing.
-      warnings.simplefilter("once", DeprecationWarning)
       fnc_test_deprecated_without_current()
       self.check_annotation(warning=w,
-                            warning_type=DeprecationWarning,
+                            warning_type=BeamDeprecationWarning,
                             obj_name='fnc_test_deprecated_without_current',
                             annotation_type='deprecated',
                             label_check_list=[('since', True),
@@ -133,7 +125,7 @@ def fnc_test_experimental_without_current():
                             annotation_type='experimental',
                             label_check_list=[('instead', False)])
 
-  def test_decapreted_custom_no_replacements(self):
+  def test_deprecated_custom_no_replacements(self):
     """Tests if custom message prints an empty string
     for each replacement token when only the
     custom_message and since parameter are given."""
@@ -144,12 +136,9 @@ def test_decapreted_custom_no_replacements(self):
       @deprecated(since=strSince, custom_message=strCustom)
       def fnc_test_experimental_custom_no_replacements():
         return 'lol'
-      # Deprecation warnings are ignored by default, turn them on
-      # to enable testing.
-      warnings.simplefilter("always", DeprecationWarning)
       fnc_test_experimental_custom_no_replacements()
       self.check_custom_annotation(warning=w,
-                                   warning_type=DeprecationWarning,
+                                   warning_type=BeamDeprecationWarning,
                                    obj_name='fnc_test_experimental_custom_no_\
                                    replacements',
                                    annotation_type='experimental',
@@ -185,13 +174,10 @@ def 
test_deprecated_with_since_current_message_custom(self):
                   custom_message=strCustom)
       def fnc_test_deprecated_with_since_current_message_custom():
         return 'lol'
-      # Deprecation warnings are ignored by default, turn them
-      # on to enable testing.
-      warnings.simplefilter("always", DeprecationWarning)
       strName = fnc_test_deprecated_with_since_current_message_custom .__name__
       fnc_test_deprecated_with_since_current_message_custom()
       self.check_custom_annotation(warning=w,
-                                   warning_type=DeprecationWarning,
+                                   warning_type=BeamDeprecationWarning,
                                    obj_name='fnc_test_deprecated_with_since_\
                                    current_message_custom',
                                    annotation_type='deprecated',
@@ -213,15 +199,11 @@ def __init__(self):
         def foo(self):
           return 'lol'
 
-      # Deprecation warnings are ignored by default, turn them
-      # on to enable testing.
-      warnings.simplefilter("always", DeprecationWarning)
-
       foo = Class_test_deprecated_with_since_current_message()
       strName = Class_test_deprecated_with_since_current_message.__name__
       foo.foo()
       self.check_annotation(warning=w,
-                            warning_type=DeprecationWarning,
+                            warning_type=BeamDeprecationWarning,
                             obj_name=strName,
                             annotation_type='deprecated',
                             label_check_list=[('since', True),
@@ -240,10 +222,6 @@ def test_experimental_with_current_message_custom(self):
       def fnc_test_experimental_with_current_message_custom():
         return 'lol'
 
-      # Deprecation warnings are ignored by default, turn them
-      # on to enable testing.
-      warnings.simplefilter("always", DeprecationWarning)
-
       strName = fnc_test_experimental_with_current_message_custom.__name__
       fnc_test_experimental_with_current_message_custom()
       self.check_custom_annotation(warning=w,


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 161786)
    Time Spent: 1h 20m  (was: 1h 10m)

> Python SDK deprecation warnings are broken
> ------------------------------------------
>
>                 Key: BEAM-5932
>                 URL: https://issues.apache.org/jira/browse/BEAM-5932
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-core
>            Reporter: Udi Meiri
>            Assignee: Udi Meiri
>            Priority: Blocker
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> [https://github.com/apache/beam/pull/6687]
> removed the line
> {code:python}
> warnings.simplefilter("once"){code}
> from annotations.py.
> This disables all deprecation warnings.
> Please fix.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to