beam icon indicating copy to clipboard operation
beam copied to clipboard

annotations should support custom messages and classes

Open kennknowles opened this issue 4 years ago • 2 comments

Update https://github.com/apache/incubator-beam/blob/python-sdk/sdks/python/apache_beam/utils/annotations.py to add 2 new features:

  1. ability to customize message
  2. ability to tag classes (not only functions)

Imported from Jira BEAM-1081. Original Jira may contain additional context. Reported by: altay.

kennknowles avatar Jun 03 '22 16:06 kennknowles

Both parts of this seem to be done already, by #6670 ("[BEAM-1081] Annotations custom message support and classes tests", merged 2018-10-17):

  1. Custom messages: annotate() and deprecated() in apache_beam/utils/annotations.py take custom_message, with %name%, %since%, %current% and %extra% placeholders.
  2. Classes: the decorator patches __new__ when the target is a class, so creating an instance emits the warning. It also adds the deprecation notice to the class docstring.

annotations_test.py covers both, for example test_deprecated_with_class and the custom_message tests. It passes on master at d8eb82acf2c (10 passed). Leaving this here in case it can be closed.

jonathansudhakar1 avatar Nov 06 '26 17:11 jonathansudhakar1

Closing as resolved by #6670 (commit 8142643373).

damccorm avatar Nov 09 '26 19:11 damccorm