File tree 3 files changed +46
-1
lines changed
3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ Find out more about isort's release policy [here](https://pycqa.github.io/isort/
9
9
- Made all exceptions pickleable.
10
10
- Fixed #1779 : Pylama integration ignores pylama specific isort config overrides.
11
11
- Fixed #1781 : ` --from-first ` CLI flag shouldn't take any arguments.
12
+ - Fixed #1792 : Sorting literals sometimes ignored when placed on first few lines of file.
12
13
13
14
### 5.9.2 July 8th 2021
14
15
- Improved behavior of ` isort --check --atomic ` against Cython files.
Original file line number Diff line number Diff line change @@ -176,10 +176,13 @@ def process(
176
176
(index == 0 or (index in (1 , 2 ) and not contains_imports ))
177
177
and stripped_line .startswith ("#" )
178
178
and stripped_line not in config .section_comments
179
+ and stripped_line not in CODE_SORT_COMMENTS
179
180
):
180
181
in_top_comment = True
181
182
elif in_top_comment and (
182
- not line .startswith ("#" ) or stripped_line in config .section_comments
183
+ not line .startswith ("#" )
184
+ or stripped_line in config .section_comments
185
+ or stripped_line in CODE_SORT_COMMENTS
183
186
):
184
187
in_top_comment = False
185
188
first_comment_index_end = index - 1
Original file line number Diff line number Diff line change @@ -1828,3 +1828,44 @@ def test_isort_should_only_add_imports_to_valid_location_issue_1769():
1828
1828
v=""""""
1829
1829
'''
1830
1830
)
1831
+
1832
+
1833
+ def test_literal_sort_at_top_of_file_issue_1792 ():
1834
+ assert (
1835
+ isort .code (
1836
+ '''"""I'm a docstring! Look at me!"""
1837
+
1838
+ # isort: unique-list
1839
+ __all__ = ["Foo", "Foo", "Bar"]
1840
+
1841
+ from typing import final # arbitrary
1842
+
1843
+
1844
+ @final
1845
+ class Foo:
1846
+ ...
1847
+
1848
+
1849
+ @final
1850
+ class Bar:
1851
+ ...
1852
+ '''
1853
+ )
1854
+ == '''"""I'm a docstring! Look at me!"""
1855
+
1856
+ # isort: unique-list
1857
+ __all__ = ['Bar', 'Foo']
1858
+
1859
+ from typing import final # arbitrary
1860
+
1861
+
1862
+ @final
1863
+ class Foo:
1864
+ ...
1865
+
1866
+
1867
+ @final
1868
+ class Bar:
1869
+ ...
1870
+ '''
1871
+ )
You can’t perform that action at this time.
0 commit comments