mark stubs for __bool__ and __nonzero__ as returning bool.

This commit is contained in:
lojack5
2025-01-11 22:27:05 -07:00
parent 62f820a8cf
commit 1fe85a8907

View File

@@ -542,6 +542,10 @@ class FunctionDef(BaseDef, FixWxPrefix):
params.append(s)
self.pyArgsString = f"({', '.join(params)})"
# __bool__ and __nonzero__ need to be defined as returning int for SIP, but for Python
# __bool__ is required to return a bool:
if (self.name or self.pyName) in ('__bool__', '__nonzero__'):
returns = ['bool']
if not returns:
self.pyArgsString = f'{self.pyArgsString} -> None'
elif len(returns) == 1: