Skip to content

Commit

Permalink
Hot fix release 5.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed Sep 30, 2020
1 parent 58cc02f commit 5282e8b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
NOTE: isort follows the [semver](https://semver.org/) versioning standard.
Find out more about isort's release policy [here](https://pycqa.github.io/isort/docs/major_releases/release_policy/).

### 5.5.4 [Hotfix] September 29, 2020
- Fixed #1507: in rare cases isort changes the content of multiline strings after a yield statement.
- Fixed #1505: Support case where known_SECTION points to a section not listed in sections.

### 5.5.3 [Hotfix] September 20, 2020
- Fixed #1488: in rare cases isort can mangle `yield from` or `raise from` statements.

Expand Down
2 changes: 1 addition & 1 deletion isort/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.5.3"
__version__ = "5.5.4"
9 changes: 0 additions & 9 deletions isort/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,6 @@ def process(
stripped_line = new_line.strip().split("#")[0]

if stripped_line.startswith("raise") or stripped_line.startswith("yield"):
if "(" in stripped_line:
while ")" not in stripped_line:
new_line = input_stream.readline()
if not new_line:
break

output_stream.write(new_line)
stripped_line = new_line.strip().split("#")[0]

while stripped_line.endswith("\\"):
new_line = input_stream.readline()
if not new_line:
Expand Down
40 changes: 40 additions & 0 deletions tests/unit/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,3 +1081,43 @@ def generator_function():
from \\
"""
assert isort.check_code(raise_from_at_file_end_ignored, show_diff=True)


def test_isort_shouldnt_mangle_from_multi_line_string_issue_1507():
"""isort was seen mangling lines that happened to contain the word from after
a yield happened to be in a file. Clearly this shouldn't happen.
See: https://github.com/PyCQA/isort/issues/1507.
"""
assert isort.check_code(
'''
def a():
yield f(
"""
select %s from (values %%s) as t(%s)
"""
)
def b():
return (
"""
select name
from foo
"""
% main_table
)
def c():
query = (
"""
select {keys}
from (values %s) as t(id)
"""
)
def d():
query = f"""select t.id
from {table} t
{extra}"""
''',
show_diff=True,
)

0 comments on commit 5282e8b

Please sign in to comment.