mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-08 21:52:48 +07:00
GitOrigin-RevId: a4225a2a8f2959947486a0bf927ff8ac388c5ccb
28 lines
713 B
HTML
28 lines
713 B
HTML
<html>
|
|
<body>
|
|
<p>Reports coroutines used in boolean contexts (if/while/ternary) without being awaited.</p>
|
|
<p>Using a coroutine object directly in a boolean condition will always evaluate to <code>True</code>,
|
|
which is likely not the intended behavior. The coroutine must be awaited to get its actual boolean value.</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
async def check() -> bool:
|
|
return True
|
|
|
|
|
|
async def main():
|
|
if check(): # Always True - coroutine object is truthy
|
|
print("hi")
|
|
</code></pre>
|
|
<p>Should be:</p>
|
|
<pre><code>
|
|
async def check() -> bool:
|
|
return True
|
|
|
|
|
|
async def main():
|
|
if await check(): # Correctly awaits the coroutine
|
|
print("hi")
|
|
</code></pre>
|
|
</body>
|
|
</html>
|