Is there a way to skip formatting (sorting) of imports or forward these lines to an external tool such as ISort?
Is this in the pipeline at all? perhaps an import_penalty variable for any modifications made to import lines?
I'm not 100% sure what @jirikuncar has in mind. (I'm sorry I missed this bug report at the time.) Is it simply to leave the imports alone and let ISort figure them out?
From my perspective it'd be great if they were left alone. I'm using pycharm to do import sorting, and then yapf as an on-save action. The problem I'm facing is that there's then no way to make pycharm win the fight as to how imports should look.
YAPF shouldn't be sorting import statements though, just reformatting them. Could you give an example of what YAPF's doing here?
the issue is when there are many imports on a single line such that the max line length is exceeded. I have pycharm set to do something like:
from package import a,b,c,d,e,
f,g,h
but yapf wants to make it either:
from package import a,
b,
c,
etc.
or
from package import
a,b,c,d,e,f,g,h
For function calls or lists etc, I prefer to have split_all_top_level_comma_separated_values=true but not for imports, on this, I would rather use isort's reformatting, but yapf will not like it, so there's no way to make both of them not to reformat imports after the other (i.e. they're fighting each other).
An option for yapf to ignore imports would prove useful.
+1 on the above comment. I have an isort set up that seems to conflict with the yapf set up and can't seem to be able to make YAPF to not reformat isort format.
Agreed, this would be awesome!
My .isort.cfg file is:
[settings]
multi_line_output=5
(to see what "5" looks like, see here)
and it seems this won't play nice with YAPF where my .style.yapf is:
[style]
based_on_style = google
A knob BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES will be available in version 0.31.0 of YAPF
any idea when 0.31.0 would be available ?
any idea when 0.31.0 would be available ?
No idea about the release schedule for YAPF. Probably a question for @gwelymernans to answer.
Most helpful comment
A knob
BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLESwill be available in version0.31.0of YAPF