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

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).


Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Evyatar Meged