Closed sphuber closed 1 year ago
Alternative solution to #264
Patch coverage: 100.00
% and no project coverage change.
Comparison is base (
090e7e9
) 90.83% compared to head (3a2e013
) 90.82%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Thanks to both for the feedback.
Fixes #262
In f47627adf0dece414c26254515f53fb7414bb3bf, the recently added check on the return type of a conditional predicate was updated slightly to only emit a warning when
None
would be returned instead of raising aTypeError
. This was done because there quite a number of workchains that unwittingly were relying on this behavior and with the change added in 800bcf154c0ea0d4576636b95d2ad2285adec266 would break all of these.Since then, it was discovered that the exception for
None
may still not be enough as it turns out that there are also quite a number of workchains that use objects that behave like booleans, but are not actually instances of the built-inbool
base type. Examples, arenumpy.bool
as well asaiida.orm.Bool
. Since here the behavior of the predicate would be as expected, breaking the existing workflow is actually not desirable.Therefore, the requirement on the return type is relaxed slightly further to any type that implements the
__bool__
method. This includesNone
, but also types likenumpy.bool
andaiida.orm.Bool
which are often used in the workchain logic by AiiDA code. There might still be edge cases where users may (accidentally) return a type from a function that does implement__bool__
but whose evaluated value is not what the user intended, but that risk is preferable then forcing users to cast bool-like instances explicit to abool
.