Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable PEP8 inspection in PyCharm IDE, except for using 2 spaces for indents? [duplicate]

Tags:

I've been using PyCharm IDE a lot recently when working with the TensorFlow Python repository. TensorFlow follows the PEP8 Python style guide, except for using 2 spaces for indents.

By default in PyCharm IDE I have the PEP8 inspection enabled to enable my codes follows PEP8 style convention. An undesirable side-effect is now I have warnings all over the place within PyCharm editor, flagging all indents (which are 2 spaces instead of 4 spaces).

If I disable PEP8 inspection, all warnings go away at the trade-off of no more PEP8 inspection (which is desirable).

Is there a way to enable full PEP8 inspection within PyCharm editor, but ignoring the 2-space indents?

Here is an example of the PEP8 warning (about indent spaces should be 4 not 2):

enter image description here

Here is a snapshot of PyCharm preferences page, under PEP8 inspection section (looks like it's either on/off - unless I'm missing something):

enter image description here

Updates

Two good options (for different purposes):

  • the suggested "duplicated question" link works well if you'd like to ignore warnings at a PyCharm-wide level. (done within the Preference)
  • the accepted answer works well if you'd only like to ignore warnings at current file / project level (without affecting other projects).
like image 673
Atlas7 Avatar asked Dec 28 '17 15:12

Atlas7


1 Answers

Put the cursor on the error being highlighted (e.g raise in your image) press Alt + Enter and choose Ignore errors like this

like image 121
Evyatar Meged Avatar answered Oct 11 '22 16:10

Evyatar Meged