> to indent some code.
Why are you manually indenting code?
I don't remember ever doing that in IDEA or VS Code for ~~python,~~ java or ts.
Edit: I borked about python, my bad.
Why are you manually indenting code?
I don't remember ever doing that in IDEA or VS Code for ~~python,~~ java or ts.
Edit: I borked about python, my bad.
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. if foo:
bar # Obviously this is indented
but_is_this() # supposed to be under the if?
how.about(this) #?
how.do_you(de) # indent in Python, if not manually? if (foo):
bar()
hum()
how can anything other than a human decide if that 3rd line should be indented as it is or by one more level?I suppose with very good tests, you might be able to catch something like this, but it seems impossible to me how a PR reviewer might catch a "bug" like this and not just assume that it's intentional.
I understand if statements not having their own scope for simplicity's sake, but the fact that `with` blocks don't is simply mind-bobbling to me. ``` with open("text.txt", 'w') as f: f.write("hello world") f.write("hello world") # at least the handle was automatically closed so it will give an IO error ```
One example would be a timing context manager:
with Timer() as t:
…
print(t.runtime)
Another example is mocks, where you want to inspect how many times a mock was called and with what arguments, after the mock context manager has finished. if foo:
bar()
and hit enter after the "bar()", it would drop you down so that the next thing you type would be under the "b". It's not really different from using curly brackets from the perspective of typing in code.