Page MenuHomeSoftware Heritage
Paste P792

WTF isort minimal
ActivePublic

Authored by vlorentz on Sep 29 2020, 5:29 PM.
$ 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}"""
$ cat db.py| isort - | diff -u db.py -
--- db.py 2020-09-29 17:30:57.737760374 +0200
+++ - 2020-09-29 17:31:42.967321279 +0200
@@ -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