| Issue |
178203
|
| Summary |
DeprecationWarnings in Clang Python bindings tests
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
Endilll
|
After recent PRs that deprecated some of the API as was suggested by #156680, we now see a number of `DeprecationWarning` in test runs
```
[4188/4188] cd /home/runner/work/llvm-project/llvm-project/clang/bindings/python && /usr/local/bin/cmake -E env CLANG_NO_DEFAULT_CONFIG=1 LIBCLANG_LIBRARY_PATH=/home/runner/work/llvm-project/llvm-project/build/lib /opt/hostedtoolcache/Python/3.13.11/x64/bin/python3.13 -m unittest discover
............/home/runner/work/llvm-project/llvm-project/clang/bindings/python/clang/cindex.py:3034: DeprecationWarning: String representation of 'CompletionChunkKind' will be changed in a future release from 'camelCase' to 'ALL_CAPS' to match other enums. 'CompletionChunkKind's can be compared to one another without conversion to string.
warnings.warn(
/home/runner/work/llvm-project/llvm-project/clang/bindings/python/clang/cindex.py:3243: DeprecationWarning: String representation of 'CompletionString.availability' will be changed in a future release from 'camelCase' to 'ALL_CAPS' to match other enums. 'CompletionString.availability' can be compared to 'AvailabilityKind' directly, without conversion to string.
warnings.warn(
...../home/runner/work/llvm-project/llvm-project/clang/bindings/python/clang/cindex.py:3096: DeprecationWarning: 'SPELLING_CACHE' has been moved into the scope of 'CompletionChunk' and adapted to use 'CompletionChunkKind's as keys instead of their enum values. Please adapt all uses of 'SPELLING_CACHE' to use 'CompletionChunk.SPELLING_CACHE' instead. The old 'SPELLING_CACHE' will be removed in a future release.
warnings.warn(self.deprecation_message, DeprecationWarning)
```
The thing is, they are expected, because deprecations came together with tests to ensure that old APIs are still working. We should inhibit those warnings in select places to keep our tests clean, presumably using [warnings.catch_warnings()](https://docs.python.org/3/library/warnings.html#warnings.catch_warnings)
```python
with warnings.catch_warnings(category=DeprecationWarning):
deprecated_api_usage()
```
CC @DeinAlptraum
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs