PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.53k stars 583 forks source link

sorts CT_R before CT_Hyperlink in import-from #2176

Closed scanny closed 1 year ago

scanny commented 1 year ago

isort with default options complains about:

from docx.oxml.text.run import CT_Hyperlink, CT_R

with "Import block is un-sorted or un-formatted"

Organize Imports code-action produces:

from docx.oxml.text.run import CT_R, CT_Hyperlink

which isort likes fine.

I was unable to narrow it down to a more abstract case like A_B and A_Bb, so just providing the exact case here.

Seems like maybe it's triggering length-sort somehow, but it's the only case I've seen and config is absolute vanilla default.

scanny commented 1 year ago

Okay, after watching this behavior more closely, my hypothesis is that it figures CT_R for a constant because it has no lowercase letters. This is the same behavior I observe when it sorts IO above BinaryIO in from typing import IO, BinaryIO.

So maybe this is on purpose.

scanny commented 1 year ago

Ok, yeah, this is the expected behavior, just me slow on grokkin' it :) Closing.