usort/sorting.py
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

        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.
        
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.
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 .
def sortable_blocks(self, body: Sequence[cst.BaseStatement]) -> List[SortableBlock]:
        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:
                    current = self.split_inplace(current, overlap)
                    blocks.append(current)
                current.add_import(imp, idx)
            else:
                current = None
        return blocks
def sortable_blocks ( self , body : Sequence [ cst . BaseStatement ] ) -> List [ SortableBlock ] : 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 : current = self . split_inplace ( current , overlap ) blocks . append ( current ) current . add_import ( imp , idx ) else : current = None return blocks
Finds blocks of imports separated by barriers (non-import statements, or
dangerous imports).
Finds blocks of imports separated by barriers ( non - import statements or dangerous imports ) .
"""
        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.
        """ # This overwrites an earlier name
self
body
Sequence[cst.BaseStatement]