def list_imports()

in usort/cli.py [0:0]


def list_imports(multiples: bool, debug: bool, filenames: List[str]) -> int:
    """
    Troubleshoot sorting behavior and show import blocks
    """
    # This is used to debug the sort keys on the various lines, and understand
    # where the barriers are that produce different blocks.

    for f in filenames:
        path = Path(f)
        config = Config.find(path)
        mod = try_parse(path)
        try:
            sorter = ImportSorter(module=mod, path=path, config=config)
            blocks = sorter.sortable_blocks(mod.body)
        except Exception as e:
            print("Exception", f, e)
            continue

        if multiples and len(blocks) < 2:
            continue

        click.secho(f"{f} {len(blocks)} blocks:", fg="yellow")
        for b in blocks:
            print(f"  body[{b.start_idx}:{b.end_idx}]")
            sorted_imports = sorted(b.imports)
            if debug:
                for imp in b.imports:
                    print(
                        f"    {sorted_imports.index(imp)} {imp} "
                        f"({imp.config.category(imp.stem or '')})"
                    )
            else:
                print("Formatted:")
                print("[[[")
                for imp in sorted_imports:
                    assert imp.node is not None
                    print(render_node(imp.node), end="")
                print("]]]")

    return 0