Python Indent plugin not working correctly?
Steven Haymes last edited by Steven Haymes
I got it on the batch file doing the heavy lifting. Your suggestion for a NppExec script to run yapf:
cmd /c yapf -i “$(FULL_CURRENT_PATH)”
is similar to my my NppExec scripts to run Pylint and Flake8:
Pylint and Flake8 only read my current Python file in NPP. They does not modify it. Does your NppExec example script that runs yapf actually modify the current Python file in NPP?
Michael Vincent last edited by
Yes, that’s what the “-i” argument to
yapf(in-place) and subsequent
NPP_OPEN- to reopen the file and force a N++ refresh do.
PS VinsWorldcom@C:\Users\VinsWorldcom> yapf -h | grep "in-place" -i, --in-place make changes to files in place
Derek Brown last edited by
Hey, this is old but I just now stumbled upon it. I am the author of this plugin.
As some of the posters above have figured out, the plugin does not attempt to follow PEP8. This is not because I have anything against PEP8, but simply I didn’t want to deal with that amount of parsing. I originally wrote this plugin to deal with the simple annoyance of having to tab every time I opened a new block. It applies a very simple heuristic of checking the start of the line for one of the keywords that open a new block in Python.
It can actually be tricked into doing the wrong thing in a number of other situations (fairly unlikely situations though), such as having a multi-line statement to open a block, or using one of those keywords at the start of a line in a multi-line string. These situations are sufficiently rare that I have never attempted to fix them. In the much more common case of line continuations (which OP is talking about), I simply manually align them with space.
If you want to get in touch with me about the plugin the best way is to open an issue on the Bitbucket page. I do not check these forums very often. I am also open to any code contributions if someone would like to tackle this.