File tree 2 files changed +47
-2
lines changed 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -458,13 +458,14 @@ def __init__(
458
458
if "src_paths" not in combined_config :
459
459
combined_config ["src_paths" ] = (path_root / "src" , path_root )
460
460
else :
461
- src_paths : Set [Path ] = set ()
461
+ src_paths : List [Path ] = []
462
462
for src_path in combined_config .get ("src_paths" , ()):
463
463
full_paths = (
464
464
path_root .glob (src_path ) if "*" in str (src_path ) else [path_root / src_path ]
465
465
)
466
466
for path in full_paths :
467
- src_paths .add (path )
467
+ if not path in src_paths :
468
+ src_paths .append (path )
468
469
469
470
combined_config ["src_paths" ] = tuple (src_paths )
470
471
Original file line number Diff line number Diff line change @@ -1345,3 +1345,47 @@ def test_multiple_configs(capsys, tmpdir):
1345
1345
_ , err = capsys .readouterr ()
1346
1346
1347
1347
assert f"{ str (file6 )} Imports are incorrectly sorted and/or formatted" in err
1348
+
1349
+
1350
+ def test_multiple_src_paths (tmpdir , capsys ):
1351
+ """
1352
+ Ensure that isort has consistent behavior with multiple source paths
1353
+ """
1354
+
1355
+ tests_module = tmpdir / "tests"
1356
+ app_module = tmpdir / "app"
1357
+
1358
+ tests_module .mkdir ()
1359
+ app_module .mkdir ()
1360
+
1361
+ pyproject_toml = tmpdir / "pyproject.toml"
1362
+ pyproject_toml .write_text (
1363
+ """
1364
+ [tool.isort]
1365
+ profile = "black"
1366
+ src_paths = ["app", "tests"]
1367
+ auto_identify_namespace_packages = false
1368
+ """ ,
1369
+ "utf-8" ,
1370
+ )
1371
+ file = tmpdir / "file.py"
1372
+ file .write_text (
1373
+ """
1374
+ from app.something import something
1375
+ from tests.something import something_else
1376
+ """ ,
1377
+ "utf-8" ,
1378
+ )
1379
+
1380
+ for _ in range (10 ): # To ensure isort has consistent results in multiple runs
1381
+ main .main ([str (tmpdir ), "--verbose" ])
1382
+ out , _ = capsys .readouterr ()
1383
+
1384
+ assert (
1385
+ file .read ()
1386
+ == """
1387
+ from app.something import something
1388
+ from tests.something import something_else
1389
+ """
1390
+ )
1391
+ assert "from-type place_module for tests.something returned FIRSTPARTY" in out
You can’t perform that action at this time.
0 commit comments