0

I configured the setting following this

https://www.jetbrains.com/help/pycharm/code-style-sql-tabs-and-indents.html

But lines with 2 space indent still get flagged by inspection as not being a multiple of 4.

I found this issue filed that is classified as reproducible confirming the issue

https://youtrack.jetbrains.com/issue/PY-51812/Customize-E111-indentation-is-not-a-multiple-of-four-inspection-

But I find that hard to believe. I know plenty of people prefer 2 spaces over 4. I must be missing something right?

Randell
  • 93
  • 9
  • Why not just choose "ignore errors like this" as described in the official resolution of the issue you linked? Seems like you missed that there was another much older post linked which has a resolution: https://youtrack.jetbrains.com/issue/PY-15202/Erroneous-PEP-8-indentation-is-not-a-multiple-of-four That issue was marked as resolved in 2015 because the resolution was to just select the option to ignore such errors. – Random Davis May 05 '22 at 18:20
  • @RandomDavis I want it to enforce the 2 spaces, not just ignore the error. We run pylint as part of our process and it will flag the non-2 space indents. – Randell May 05 '22 at 18:22
  • You didn't mention PyLint at all but there's also a solution for that, [here](https://stackoverflow.com/questions/54117674/how-can-i-change-pylint-tab-width-from-4-spaces-to-2-spaces); why won't that work either? – Random Davis May 05 '22 at 18:24
  • @RandomDavis pylint works fine, there is a plugin for it but it is too heavy and slow. So it is only run on demand, and as part of the ci/cd flow. The issue here is when editing code, pycharm is flagging correct code (2 space indent) that will pass pylint. And it seems the only thing that can be done it to turn off indentation checking. Rather than configure it to enforce 2 spaces so you won't fail pylint later down the line. Since pycharm lets you configure tab to be 2 spaces and such, I can't figure out why the inspection can't be configured. – Randell May 05 '22 at 18:33
  • I don't think this is possible, [see this thread](https://stackoverflow.com/a/64081934) there's no setting in the IDE to fine-tune the bundled pycodestyle settings. What you could *maybe* do would be editing configuration file of pycodestyle that's installed with PyCharm, but that's a hack will reflect IDE wide since ATM there's no way to have the bundled pycodestyle read costum configuration files. – bad_coder May 07 '22 at 20:09

0 Answers0