Open alexreg opened 1 year ago
I suspect the easiest solution to this problem (given that the generalised problem of detecting when the import section ends is non-trivial) is to provide an option simply to disable "fixing" the number of lines after the input section and let the formatter (like black or yapf) deal with this. The same goes for comments at the end of a line.
I seems that isort does not cope well with import sections that contain conditionals. Here's an example from a package I author (and a fairly common scenario at that).
isort wants to put two lines (the
lines_after_imports
value) afterimport sys
. The problem is evidently that it incorrectly detects the end of imports to be here rather than the true location, which is just before the setting of__version__
.There's also the issue that it puts two spaces instead of one before
# pragma: no cover
, and this does not seem possible to configure. (I'm not sure thecomment_prefix
option works as intended, since it can only be used to change the#
character.)For reference, this is the incorrect output after running through isort.