Commit ebbb9891 authored by Łukasz Langa's avatar Łukasz Langa
Browse files

Make schedule_formatting logic less nested.

parent 1dbe77cd
Loading
Loading
Loading
Loading
+4 −2
Changes for black.py: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -431,9 +431,11 @@ async def schedule_formatting(
        sources, cached = filter_cached(cache, sources)
        for src in sorted(cached):
            report.done(src, Changed.CACHED)
    if not sources:
        return

    cancelled = []
    sources_to_cache = []
    if sources:
    lock = None
    if write_back == WriteBack.DIFF:
        # For diff output, we need locks to ensure we don't interleave output
@@ -458,7 +460,7 @@ async def schedule_formatting(
        loop.add_signal_handler(signal.SIGINT, cancel, pending)
        loop.add_signal_handler(signal.SIGTERM, cancel, pending)
    except NotImplementedError:
            # There are no good alternatives for these on Windows
        # There are no good alternatives for these on Windows.
        pass
    while pending:
        done, _ = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)