facebook/usort

cProfile isn't considered stdlib

thatch opened this issue · 0 comments

I suspect this was broken with the case-related changes in #19 and reusing SortableImport.first_module for sorting as well as section detection.

This is properly sorted and formatted:

import cProfile
import os

but current (0.5.0a3) insists on putting cProfile last, outside the stdlib section.

$ usort list-imports --debug temp.py
temp.py 1 blocks:
  body[0:2]
    1 SortableImport(sort_key=SortKey(category_index=2, is_from_import=False, ndots=0), first_module='cprofile', first_dotted_import='cprofile', imported_names={'cProfile': 'cProfile'}) (third_party)
    0 SortableImport(sort_key=SortKey(category_index=1, is_from_import=False, ndots=0), first_module='os', first_dotted_import='os', imported_names={'os': 'os'}) (standard_library)