@@ -4154,6 +4154,74 @@ def test_isort_keeps_comments_issue_691() -> None:
4154
4154
assert SortImports (file_contents = test_input ).output == expected_output
4155
4155
4156
4156
4157
+ def test_isort_ensures_blank_line_between_import_and_comment () -> None :
4158
+ config = {
4159
+ "ensure_newline_before_comments" : True ,
4160
+ "known_one" : ["one" ],
4161
+ "known_two" : ["two" ],
4162
+ "known_three" : ["three" ],
4163
+ "known_four" : ["four" ],
4164
+ "sections" : [
4165
+ "FUTURE" ,
4166
+ "STDLIB" ,
4167
+ "FIRSTPARTY" ,
4168
+ "THIRDPARTY" ,
4169
+ "LOCALFOLDER" ,
4170
+ "ONE" ,
4171
+ "TWO" ,
4172
+ "THREE" ,
4173
+ "FOUR" ,
4174
+ ],
4175
+ } # type: Dict[str, Any]
4176
+ test_input = (
4177
+ "import os\n "
4178
+ "# noinspection PyUnresolvedReferences\n "
4179
+ "import one.a\n "
4180
+ "# noinspection PyUnresolvedReferences\n "
4181
+ "import one.b\n "
4182
+ "# noinspection PyUnresolvedReferences\n "
4183
+ "import two.a as aa\n "
4184
+ "# noinspection PyUnresolvedReferences\n "
4185
+ "import two.b as bb\n "
4186
+ "# noinspection PyUnresolvedReferences\n "
4187
+ "from three.a import a\n "
4188
+ "# noinspection PyUnresolvedReferences\n "
4189
+ "from three.b import b\n "
4190
+ "# noinspection PyUnresolvedReferences\n "
4191
+ "from four.a import a as aa\n "
4192
+ "# noinspection PyUnresolvedReferences\n "
4193
+ "from four.b import b as bb\n "
4194
+ )
4195
+ expected_output = (
4196
+ "import os\n "
4197
+ "\n "
4198
+ "# noinspection PyUnresolvedReferences\n "
4199
+ "import one.a\n "
4200
+ "\n "
4201
+ "# noinspection PyUnresolvedReferences\n "
4202
+ "import one.b\n "
4203
+ "\n "
4204
+ "# noinspection PyUnresolvedReferences\n "
4205
+ "import two.a as aa\n "
4206
+ "\n "
4207
+ "# noinspection PyUnresolvedReferences\n "
4208
+ "import two.b as bb\n "
4209
+ "\n "
4210
+ "# noinspection PyUnresolvedReferences\n "
4211
+ "from three.a import a\n "
4212
+ "\n "
4213
+ "# noinspection PyUnresolvedReferences\n "
4214
+ "from three.b import b\n "
4215
+ "\n "
4216
+ "# noinspection PyUnresolvedReferences\n "
4217
+ "from four.a import a as aa\n "
4218
+ "\n "
4219
+ "# noinspection PyUnresolvedReferences\n "
4220
+ "from four.b import b as bb\n "
4221
+ )
4222
+ assert SortImports (file_contents = test_input , ** config ).output == expected_output
4223
+
4224
+
4157
4225
def test_pyi_formatting_issue_942 (tmpdir ) -> None :
4158
4226
test_input = "import os\n \n \n def my_method():\n "
4159
4227
expected_py_output = test_input .splitlines ()
0 commit comments