Skip to content

Semicolon in decorator confuses lines_after_imports #1178

@FuegoFro

Description

@FuegoFro

If you have a decorator on the first class or function after imports that has a semicolon in the line (eg, in a string) it confuses the lines_after_imports setting into only putting a single blank line, when there should in fact be two. Here's a minimal repro:

import pytest

@pytest.mark.skip(';')
def test_thing(): pass

Removing the semicolon in the @pytest.mark.skip(';') line (eg having it be an empty string) causes it to put two blank lines after imports (as expected here).

This bug causes isort to conflict with black (though a workaround is to just put a pass between the imports and the class or function).

This was tested on latest master at time of writing (1621e19).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions