[clang] [libclang/python] Fix some type errors, add type annotations (PR #98745)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 21 04:37:43 PDT 2024
================
@@ -200,13 +236,16 @@ class _CXString(Structure):
_fields_ = [("spelling", c_char_p), ("free", c_int)]
- def __del__(self):
+ def __del__(self) -> None:
conf.lib.clang_disposeString(self)
@staticmethod
- def from_result(res, fn=None, args=None):
+ def from_result(res: _CXString, fn: Any = None, args: Any = None) -> str:
assert isinstance(res, _CXString)
- return conf.lib.clang_getCString(res)
+ pystr: str | None = conf.lib.clang_getCString(res)
+ if pystr is None:
+ return ""
+ return pystr
----------------
DeinAlptraum wrote:
The interface changes, isn't that a breaking change in every case? I.e. if you were checking for empty results before by doing `is None`, that doesn't work anymore. You would now have to change that to `== ""`.
I've added a breaking change note for this, but happy to remove this again if I'm missing something here.
https://github.com/llvm/llvm-project/pull/98745
More information about the cfe-commits
mailing list