-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hanging indent options on continuation lines #63
Comments
It looks like you've set your indentation size in VSCode to 2 spaces, is that correct? The problem is that Just googling around, it looks like this package may handle your use case: https://pypi.org/project/flake8-tabs/ There also seems to be an open PR in |
Thanks for the response. Indeed my indentation size in VSCode is 2 spaces. The current behavior of the linter is fine by me. I'm trying to get the editor itself to automatically add 2 tabs (i.e. 4 spaces) when I add a new line on an open parenthesis. I'm doing this to follow the Tensorflow style guide (e.g. Colab's editor follows the desired behavior). But I understand this is a pretty niche use case. |
The tensorflow style guide tells you to "follow the PEP 8 Python style guide, except TensorFlow uses 2 spaces instead of 4". PEP8 says that continuation lines should use "an extra level of indentation", which in your case is 2 spaces, i.e. the current behavior. |
Flake8 isn't calling for you to have two levels of indentation, it just expects you to be using four spaces instead of two. That's why I linked you to those two pieces of information on getting flake8 to handle two-space-indentations correctly. |
Thank you for following up. I think the Tensorflow style guide is ambiguous as to when tabs should be 2 spaces. I know Colab and Tensorflow source code use 2 spaces for most tabs but 4 spaces on continuation line indents. But I also understand that PEP 8 only expects one level of indentation. Regardless of which level of indentation is preferred, it would be great to have the ability to customize continuation line indents, if possible. |
Someone should update the TF style guide to be accurate, they're not following PEP8. And, in my opinion, their double-indent-for-continuations might just be the dumbest python style convention I've ever seen. I'm not going to work on this, but feel free to submit a pull request. If you do please write good unit tests -- each additional configuration that is added to this extension exponentially increases the amount of manual testing I do before a new release. I need to be sure it has good automated tests backing up my manual testing. |
Got it, thank you! I'll probably hold off on a pull request for now, but I'll let you know if I end up working on it. |
First of all, I love this extension. It has made using VS Code such a breeze, so thank you immensely for making it available.
This may be closer to a feature request, but it would be great to have indentation options for continuation lines. There are no hard and fast rules here, but some linters call for four spaces for indents on continuation lines (e.g. Flake8 E121). That is, some linters call for using two tabs on new lines as opposed to one. To be concrete,
Minimal code example:
What the code looks like before pressing
enter
:What I want the code to look like after pressing
enter
:What the code actually looks like after pressing
enter
:Obviously this is subject to personal taste, but it would be great to have indentation options so e.g. the Flake8 preference could be applied by default, if desired by the user. Thanks a lot!
The text was updated successfully, but these errors were encountered: