You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this code, a likely fix is to change func() to await func(). Meanwhile, it'll always be true since a Coroutine is always true. The truthy-bool check could flag it but it's not enabled by default. We can add a new truthy-coroutine check (like truthy-function) for the specific case of using a Coroutine in boolean context.
The error message can suggest that an await might've been mistakenly omitted.
main.py:5: error: "__main__.func" returns "Coroutine[Any, Any, bool]" which does not implement __bool__ or __len__ so it could always be true in boolean context [truthy-bool]
Activity
Added check for a conditional expression that evaluates to a coroutin…
sterliakov commentedon May 4, 2025
This is supported with
--enable-error-code truthy-bool! https://mypy-play.net/?mypy=latest&python=3.12&flags=strict&enable-error-code=truthy-bool%2Cunused-awaitable&gist=90f4e135d45763cdec86fe1917507f93ikonst commentedon May 5, 2025
@sterliakov You misread the report. I'm aware that truthy-bool would report it.
sterliakov commentedon May 5, 2025
Indeed, my apologies!