Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isort changes the content of multiline strings after a yield statement #1507

Closed
progval opened this issue Sep 29, 2020 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@progval
Copy link

progval commented Sep 29, 2020

Hi,

If there is a yield statement in a file, isort alters multiline strings that contain the word "from":

$ cat db.py                           
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}"""
$ isort --diff db.py 
--- /home/dev/swh-environment/swh-indexer/db.py:before	2020-09-29 17:30:57.737760
+++ /home/dev/swh-environment/swh-indexer/db.py:after	2020-09-29 17:44:02.722392
@@ -9,7 +9,6 @@
     return (
         """
         select name
-        from foo
         """
         % main_table
     )
@@ -18,12 +17,11 @@
     query = (
         """
         select {keys}
-        from (values %s) as t(id)
+        from values%s import ast, id
         """
     )
 
 def d():
     query = f"""select t.id
-                from {table} t
                 {extra}"""
$ isort -V                            

                 _                 _
                (_) ___  ___  _ __| |_
                | |/ _/ / _ \/ '__  _/
                | |\__ \/\_\/| |  | |_
                |_|\___/\___/\_/   \_/

      isort your imports, so you don't have to.

                    VERSION 5.5.3

isort was installed using pip3 install --user isort earlier today.

@progval progval changed the title Changes the content of multiline strings after a yield statement isort changes the content of multiline strings after a yield statement Sep 29, 2020
@timothycrosley timothycrosley added the bug Something isn't working label Sep 30, 2020
@timothycrosley
Copy link
Member

Thank you for reporting this major issue! A 5.5.4 hot fix release was released that resolves it and I was able to confirm it is only present in the 5.5.3 release.

Thanks!

~Timothy

@progval
Copy link
Author

progval commented Sep 30, 2020

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants