2 ms·
For example, you have if check_something(): wall_of_text = textwrap.dedent(""" this is a multiline string """.strip("\n"))
by rfoo 2y ago
For example, you have
if check_something():
wall_of_text = textwrap.dedent("""
this
is
a
multiline
string
""".strip("\n"))
I hope you agree it's ugly. And you want to make it
if check_something():
wall_of_text = textwrap.dedent("""\
this
is
a
multiline
string
""".strip("\n"))
But I don't know any formatter which does this automatically. Because the change here not only changes the looking, it changes semantic. The formatter has to understand that after `textwrap.dedent(_.strip("\n"))` the result does not change and that's hard. So formatter just leave it alone. But it's extremely obvious to a human. Or maybe extremely obvious to a LLM too.
- Mashimo 2y agoYeah, string """ blocks I also have to do manually. Though that example never interfered with AI autocomplete in my experience.