From 1fe85a89079f7f0f53d1fd8ccd112a77cda752d8 Mon Sep 17 00:00:00 2001 From: lojack5 <1458329+lojack5@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:27:05 -0700 Subject: [PATCH] mark stubs for `__bool__` and `__nonzero__` as returning `bool`. --- etgtools/extractors.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etgtools/extractors.py b/etgtools/extractors.py index 2d9d0c42..193b9e02 100644 --- a/etgtools/extractors.py +++ b/etgtools/extractors.py @@ -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: