diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-09-29 21:37:18 -0700 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-09-29 21:37:18 -0700 |
commit | 3e4f45b0b10e5d25f67682287a9d9962fe2d8fd2 (patch) | |
tree | 3e0184bf6a9b9f8614edb9f7f0900a92edd214f3 | |
parent | f46a07680e90d46b429df7337c50536d305d5f64 (diff) | |
parent | 2e02c195afdb499be9068ca0d08c9d7d45912d4d (diff) | |
download | isort-3e4f45b0b10e5d25f67682287a9d9962fe2d8fd2.tar.gz |
Merge branch 'master' of https://github.com/timothycrosley/isort into develop
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | isort/_version.py | 2 | ||||
-rw-r--r-- | isort/core.py | 9 | ||||
-rw-r--r-- | pyproject.toml | 2 | ||||
-rw-r--r-- | tests/unit/test_regressions.py | 40 |
5 files changed, 45 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f40c3fd..60c8dac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ Find out more about isort's release policy [here](https://pycqa.github.io/isort/ - Fixed #1482: pylama integration is not working correctly out-of-the-box. - Fixed #1492: --check does not work with stdin source. - Fixed #1499: isort gets confused by single line, multi-line style comments when using float-to-top. + +### 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 diff --git a/isort/_version.py b/isort/_version.py index 16b899cb..e82c92eb 100644 --- a/isort/_version.py +++ b/isort/_version.py @@ -1 +1 @@ -__version__ = "5.5.3" +__version__ = "5.5.4" diff --git a/isort/core.py b/isort/core.py index 11ae35f9..22cba49e 100644 --- a/isort/core.py +++ b/isort/core.py @@ -376,15 +376,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: diff --git a/pyproject.toml b/pyproject.toml index db979b71..0e04251c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ line-length = 100 [tool.poetry] name = "isort" -version = "5.5.3" +version = "5.5.4" description = "A Python utility / library to sort Python imports." authors = ["Timothy Crosley <timothy.crosley@gmail.com>"] license = "MIT" diff --git a/tests/unit/test_regressions.py b/tests/unit/test_regressions.py index 5c609d20..5dc2fc81 100644 --- a/tests/unit/test_regressions.py +++ b/tests/unit/test_regressions.py @@ -1158,3 +1158,43 @@ x = 1 float_to_top=True, 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, + ) |