I am trying to type hint a walrus operator expression, i.e.
while (var: int := some_func()): ...
How can I do this?
It's not possible. From PEP 572
Inline type annotations are not supported:
You need to declare the variable before the while loop, and you can specify the type there.
var: int
while var := some_func():
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With