prefer-walrus-stream-loop
Collapse a compact producer assignment and immediate sentinel break into a named-expression loop.
Why
A named-expression loop can state a repeated producer call and its termination condition together.
Fix
For if not value: break, use while (value := read()):. For if value is None: break, preserve the sentinel with while (value := read()) is not None:.
Examples
while True: message = receive() if message is None: break consume(message)while (message := receive()) is not None: consume(message)while True: chunk = stream.read(8192) if not chunk: break process(chunk)while chunk := stream.read(8192): process(chunk)