Add Python generator support for deprecated interface fields#252
Open
Pengkun-ZHU wants to merge 1 commit intoros2:kiltedfrom
Open
Add Python generator support for deprecated interface fields#252Pengkun-ZHU wants to merge 1 commit intoros2:kiltedfrom
Pengkun-ZHU wants to merge 1 commit intoros2:kiltedfrom
Conversation
Implements the Python generator side of field-level deprecation support. This PR is based on and should be merged as a companion to ros2/rosidl#945, which establishes the IDL annotation pipeline for C and C++ generators. When a message field is annotated with @deprecated(text=...) in an .idl file, the generated Python message class will: - Decorate the property getter and setter with @typing_extensions.deprecated(text) (PEP 702), enabling static analysis tools (mypy, pyright, IDEs) to flag deprecated field usage at development time - Emit a DeprecationWarning at runtime when the field is accessed or set The C extension (_msg_support.c.em) wraps internal accesses to deprecated fields with DISABLE_DEPRECATED_PUSH/POP to suppress warnings in generated conversion code. Changes: - resource/_msg.py.em: import and apply @_deprecated decorator on getter/setter when field has @deprecated annotation - resource/_msg_support.c.em: suppress deprecation warnings around internal PyObject_GetAttrString/SetAttrString calls - package.xml: add python3-typing-extensions exec_depend - CMakeLists.txt: add TestDeprecated.idl test message and test_deprecated.py regression test Signed-off-by: Pengkun-ZHU <q1091803103@gmail.com>
Author
|
@InvincibleRMC @jmachowinski, I did a Python support following the implementation in ros2/rosidl#945. Could you help give it a review? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the Python generator side of field-level deprecation support. This PR is based on and should be merged as a companion to ros2/rosidl#945, which establishes the IDL annotation pipeline for C and C++ generators.
When a message field is annotated with
@deprecated(text='...')in an .idl file, the generated Python message class will:@typing_extensions.deprecated(text)(PEP 702), enabling static analysis tools (mypy, pyright, IDEs) to flag deprecated field usage at development timeDeprecationWarningat runtime when the field is accessed or setThe C extension _msg_support.c.em wraps internal accesses to deprecated fields with
DISABLE_DEPRECATED_PUSH/POPto suppress warnings in generated conversion code.Related