Author: Jannick Kremer Date: 2026-01-26T20:13:11+09:00 New Revision: 7d60fe3cbd564ed2defdbe96472230ae2afe8115
URL: https://github.com/llvm/llvm-project/commit/7d60fe3cbd564ed2defdbe96472230ae2afe8115 DIFF: https://github.com/llvm/llvm-project/commit/7d60fe3cbd564ed2defdbe96472230ae2afe8115.diff LOG: [libclang/python] Add deprecation warnings to CompletionChunk.isKind methods (#177854) This adresses point 3 from https://github.com/llvm/llvm-project/issues/156680. --------- Co-authored-by: Vlad Serebrennikov <[email protected]> Added: Modified: clang/bindings/python/clang/cindex.py clang/docs/ReleaseNotes.rst Removed: ################################################################################ diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 6d667c36ef9a4..38799edb04744 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -3157,19 +3157,55 @@ def string(self) -> CompletionString | None: return None return CompletionString(res) + __deprecation_message = ( + "'CompletionChunk.{}' will be removed in a future release. " + "All uses of 'CompletionChunk.{}' should be replaced by checking " + "if 'CompletionChunk.kind` is equal to 'CompletionChunkKind.{}'." + ) + def isKindOptional(self) -> bool: + deprecation_message = self.__deprecation_message.format( + "isKindOptional", + "isKindOptional", + "OPTIONAL", + ) + warnings.warn(deprecation_message, DeprecationWarning) return self.kind == CompletionChunkKind.OPTIONAL def isKindTypedText(self) -> bool: + deprecation_message = self.__deprecation_message.format( + "isKindTypedText", + "isKindTypedText", + "TYPED_TEXT", + ) + warnings.warn(deprecation_message, DeprecationWarning) return self.kind == CompletionChunkKind.TYPED_TEXT def isKindPlaceHolder(self) -> bool: + deprecation_message = self.__deprecation_message.format( + "isKindPlaceHolder", + "isKindPlaceHolder", + "PLACEHOLDER", + ) + warnings.warn(deprecation_message, DeprecationWarning) return self.kind == CompletionChunkKind.PLACEHOLDER def isKindInformative(self) -> bool: + deprecation_message = self.__deprecation_message.format( + "isKindInformative", + "isKindInformative", + "INFORMATIVE", + ) + warnings.warn(deprecation_message, DeprecationWarning) return self.kind == CompletionChunkKind.INFORMATIVE def isKindResultType(self) -> bool: + deprecation_message = self.__deprecation_message.format( + "isKindResultType", + "isKindResultType", + "RESULT_TYPE", + ) + warnings.warn(deprecation_message, DeprecationWarning) return self.kind == CompletionChunkKind.RESULT_TYPE diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a5340a31d4fe9..3f4962bac9d09 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -303,6 +303,13 @@ Sanitizers Python Binding Changes ---------------------- +- Add deprecation warnings to ``CompletionChunk.isKind...`` methods. + These will be removed in a future release. Existing uses should be adapted + to directly compare equality of the ``CompletionChunk`` kind with + the corresponding ``CompletionChunkKind`` variant. + + Affected methods: ``isKindOptional``, ``isKindTypedText``, ``isKindPlaceHolder``, + ``isKindInformative`` and ``isKindResultType``. OpenMP Support -------------- _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
