def sortable_blocks()

in usort/sorting.py [0:0]


    def sortable_blocks(self, body: Sequence[cst.BaseStatement]) -> List[SortableBlock]:
        """
        Finds blocks of imports separated by barriers (non-import statements, or
        dangerous imports).  We will only sort within a block, and only when there
        are no duplicate names.
        """
        blocks: List[SortableBlock] = []
        current: Optional[SortableBlock] = None
        for idx, stmt in enumerate(body):
            if self.is_sortable_import(stmt):
                assert isinstance(stmt, cst.SimpleStatementLine)
                imp = import_from_node(stmt, self.config)
                if current is None:
                    current = SortableBlock(idx, idx + 1)
                    blocks.append(current)

                overlap = self.name_overlap(current, imp)
                if overlap:
                    # This overwrites an earlier name
                    current = self.split_inplace(current, overlap)
                    blocks.append(current)

                current.add_import(imp, idx)
            else:
                current = None
        return blocks