PyCQA / flake8-import-order

Flake8 plugin that checks import order against various Python Style Guides
GNU Lesser General Public License v3.0
278 stars 72 forks source link

isort-compatible style #177

Closed Dreamsorcerer closed 1 year ago

Dreamsorcerer commented 3 years ago

Would be nice to have an isort-compatible style built-in.

This would appear to be the same as the pycharm style, but with ordering done as: from foo import GLOBAL_VAR, ClassName, func rather than from foo import ClassName, GLOBAL_VAR, func

i.e. it needs to group the ordering into 3 parts, ALLCAPS, CapWords and lowercase.

Sorting code for this could be as simple as:

group = lambda k: 0 if k.isupper() else 2 if k.islower() else 1
key = lambda k: (group(k), k)

>>> a = ("GLOBAL_VAR", "ClassName", "func")
>>> sorted(a, key=key)
['GLOBAL_VAR', 'ClassName', 'func']
sigmavirus24 commented 3 years ago

See #163. Requests for work on the part of the maintainers ("Would be nice ...") aren't going to be actioned.