Please see the below code:
class Worker:
"""Asynchronous worker."""
def wait(self) -> bool:
"""Wait for worker thread to join."""
# Code wraps threading.Event.wait()
def wait_all(*workers: Worker) -> bool:
return all([w.wait() for w in workers]) # List stops short circuit
With ruff==0.0.265, and running ruff --select=C419 --fix a.py, it removes the list cast:
def wait_all(*workers: Worker) -> bool:
return all(w.wait() for w in workers) # List stops short circuit
However, this actually added a subtle bug, because now the all statement will be short-circuited. This short circuiting (in my scenario here) will cause all workers beyond the first w.wait() return of False to not be awaited.
I think C4 autofixing should not be applied within all/any, as these can be short circuited, which can cause undesirable side effects.