PyCQA / isort

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

aliases can cause isort to add backslashes even with multi_line_output=5 #466

Closed cjerdonek closed 7 years ago

cjerdonek commented 8 years ago

When multi_line_output is set to 5 (which should result in parentheses), isort can still introduce backslashes. This can be seen in the Django project, for example, which sets it to 5 and yet still has the following:

from django.db.backends.mysql.base import \
    DatabaseWrapper as MySQLDatabaseWrapper
jcb91 commented 7 years ago

I see this on single-item imports which are nevertheless too long for a single line, even without aliases. I set mutliline to 5 in setup.cfg but still get complaints about this import as follows:

--- /home/travis/build/jcb91/jupyter_contrib_nbextensions/src/jupyter_contrib_nbextensions/install.py:before    2016-12-28 13:18:28.647867
+++ /home/travis/build/jcb91/jupyter_contrib_nbextensions/src/jupyter_contrib_nbextensions/install.py:after 2016-12-28 13:19:50.188283
@@ -12,9 +12,8 @@
 import latex_envs
 import psutil
 from jupyter_contrib_core.notebook_compat import nbextensions
-from jupyter_nbextensions_configurator.application import (
-    EnableJupyterNbextensionsConfiguratorApp,
-)
+from jupyter_nbextensions_configurator.application import \
+    EnableJupyterNbextensionsConfiguratorApp
 from traitlets.config import Config
 from traitlets.config.manager import BaseJSONConfigManager

(see https://travis-ci.org/jcb91/jupyter_contrib_nbextensions/jobs/187200090#L417-L429 for actual logs of isort call)

timothycrosley commented 7 years ago

Closing as this is now resolved in develop and will make it into the next release.

Thanks!

~Timothy

mattbennett commented 5 years ago

For others stumbling across this issue, it took me a while to realise that this is resolved _by using the use_parentheses_ config option. Setting multi_line_output=5 is not sufficient on its own.