timothycrosley/isort — pull request #179 by dandavison (2014-09-11 05:37:26+00:00)
Title: Dont strip `as` comments

See #125

This PR contains test cases and fixes for a bug relating to inline comments on `import ... as ...` lines.

Examples of the incorrect behavior are (all invocations of `isort` are with default options, i.e. `isort -d $file`):

#### Example 1

```
from a import b as bb # b comment
from a import c as cc # c comment
```

On 3.9.0 this has its comments stripped; with this PR it is left unchanged.

#### Example 2

```
from a import b as bb # b comment
from a import c as cc # c comment
from a import d
```

was being converted to (branch `develop` 3.9.0)

```
from a import b as bb
from a import c as cc
from a import d # b comment; c comment
```

with this PR it is left unchanged.

Note that there is an option `'combine_as_imports'` but it is not (AIUI) exposed to the user in the command line API. If that option is set to `True` by manually editing `isort/settings.py`, we do get the desired output for these examples (one of the test cases confirms this).

```
from a import b as bb, c as cc # b comment; c comment
```

```
from a import b as bb, c as cc, d # b comment; c comment
```