I have an annoying issue with Python indentation. I don’t really plan my code — I just start writing — so fixing indentation later becomes insanely frustrating. It got me wondering: what are the best Python extensions or tools for this (or for Python in general)?
Edit - Let me set the context — I didn’t explain this properly earlier.
I forgot to wrap my main() logic in a try/except, and after adding it, I had to manually re-indent this whole match block — which was annoying.
Code:-
match args.command:
case "add" : cmdAdd(args)
case "init" : cmdInit(args)
case "commit" : cmdCommit(args)
case "status" : cmdStatus(args)
case "tag" : cmdTag(args)
case _ : print("Bad command.")
I know I can select everything and press Tab, but that still feels like a hassle. I come from Go, where I mostly just move curly braces and the formatter handles the rest.
Is there any shortcut or extension that can automatically refactor/indent a selected Python block when wrapping it in something like try/except?