Repository navigation
Commit cb179db
Keep add_imports below a prefixed module docstring
The guard that stops isort inserting add_imports above a module docstring tests the raw line against COMMENT_INDICATORS, so it only recognises a docstring that starts with a quote. A docstring carrying a legal string prefix (r, b, f, u or a combination) starts with a letter, the guard misses it, and the import is inserted above the docstring - and, because the file already contained that import, duplicated. Single-line prefixed docstrings escape this by accident, via the neighbouring endswith(DOCSTRING_INDICATORS) guard; multi-line ones do not. Strip a legal string prefix before the quote-based check. Closes #1893.1 parent 7542f76 commit cb179db
2 files changed
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
37 | 50 | | |
38 | 51 | | |
39 | 52 | | |
| |||
427 | 440 | | |
428 | 441 | | |
429 | 442 | | |
430 | | - | |
| 443 | + | |
431 | 444 | | |
432 | 445 | | |
433 | 446 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2460 | 2460 | | |
2461 | 2461 | | |
2462 | 2462 | | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
0 commit comments