deshaw / pyflyby

A set of productivity tools for Python
https://deshaw.github.io/pyflyby/
Other
347 stars 52 forks source link

Custom implementation of import sorting. #329

Closed Carreau closed 4 months ago

Carreau commented 5 months ago

This tries to implement some of the rule of import sorting as requested in #13 using custom logic, This was originally fixed in #263 using isort, but reverted and re-requested as of #287

Current this has the following limitations/bugs that will need to be sorted out, but might need fixes to Pyflyby master branch first.

This can be tried with the --experimental-sort-imports


C, (and likely B), is I think a bug in Pyflyby parsing where new lines are part of the next statement (especially if it is a comment) instead of being part of the previous one – or being their own statement. It might affect strings literal as well (to check). See #328

From what I can tell this may change API, so I want to be careful fixing this.

Carreau commented 4 months ago

I managed to fix the whitespace issue which took a lot of refactor. Way too much, and way more than I expected.

As this is behind an experiemental flag I'm going to merge it, and we can iterate.