When using --multi-imports, the import line will grow to arbitrary
lengths, even though this will fail the line length lint check.
This change adds a --max-line-length option to set the maximum line
length to use, using the value from the setup.cfg file as default.
This option is then used to break from-imports lines into multiple
lines if they are longer than the specified length.
For example, this line
from zimports import ClassifiedImport, ImportVisitor, sort_imports, main
will, when run with --max-line-length=72 be transformed to
from zimports import (
ClassifiedImport, ImportVisitor, sort_imports, main)
The heavy lifting is done using the built-in textwrap module.
The tests did not pass when using the asname= keyword argument to
ast_cls, I'm assuming this is due to running on python 3.6.
I've also taken the liberty to use the built-in version of the mock
module, which has been there since python 3.3.
When using --multi-imports, the import line will grow to arbitrary lengths, even though this will fail the line length lint check.
This change adds a --max-line-length option to set the maximum line length to use, using the value from the setup.cfg file as default. This option is then used to break from-imports lines into multiple lines if they are longer than the specified length.
For example, this line
will, when run with --max-line-length=72 be transformed to
The heavy lifting is done using the built-in textwrap module.
The tests did not pass when using the asname= keyword argument to ast_cls, I'm assuming this is due to running on python 3.6.
I've also taken the liberty to use the built-in version of the mock module, which has been there since python 3.3.