Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable special naming convention inspection of PEP 8 in PyCharm

I installed PyCharm and enabled pep8 checks in Inspections. If I write:

def func(argOne):
    print(argOne)

The IDE shows me this warning: Argument name should be lowercase

There is no option to ignore only such inspection.
I cant find such error number to ignore in pep8
here are all the naming inspections.
how to ignore only some of them?

I need this because the current project coding guidelines must be kept. It's too hard to change the guidelines of the whole project.

I need to disable only some naming inspections. Not all like by "Settings"-> "Editor"-> "Inspections"->"PEP8 coding style violation".
e.g. class names should be still inspected with PEP8, and function argument names not.

like image 617
ya_dimon Avatar asked Oct 15 '15 16:10

ya_dimon


People also ask

How do I turn off PyCharm warnings?

Disable inspectionsIn the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | Inspections. Locate the inspection you want to disable, and clear the checkbox next to it. Apply the changes and close the dialog.

Does PyCharm check for PEP8?

So, as you can see, PyCharm supports PEP8 as the official Python style guide.

What is inspection in PyCharm?

Code inspections In PyCharm, there is a set of code inspections that detect and correct abnormal code in your project. The IDE can find and highlight various problems, locate dead code, find probable bugs, spelling problems, and improve the overall code structure.


4 Answers

Since PyCharm 2.7 you can hover over the inspected code and use the light bulb to Ignore errors like this.

highlighted code ignore errors

Further more you can manage the ignored errors at Settings > Editor > Inspections > Python > PEP 8 naming convention violation > Ignored errors

pep8 naming convention settings

Tested in PyCharm Community Edition 2016.3.2

Edit:

To remove the modification later on you can use filter button to Show Only Modified Inspections and delete the Ignored errors with remove button

inspection filter

Tested in PyCharm Community Edition 2017.2.3

like image 84
Cani Avatar answered Oct 20 '22 05:10

Cani


Using PyCharm 5 (community edition), you can do the following. Code -> Inspect Code. Then select the required inspection error, and click on the "Suppress" option on right hand side. Please see screenshot below:

PyCharm 5 Inspection

Once you have done this, it adds a comment as shown in screenshot below:

Result

As already mentioned in other comments, you should perhaps question why you are suppressing PEP8 guidelines. However, sometimes it appears necessary, for instance using the pytest module it is necessary to shadow variables etc which PEP8 Inspection complains about in which case this feature in PyCharm is very helpful.

like image 27
arcseldon Avatar answered Oct 20 '22 07:10

arcseldon


Argh! This was frustrating to me as well.

It is the only warning I disagree with. Anyways, you can fix it by flicking this checkbox in the image.

How to turn off the warnings against camelCase

like image 3
Erik Bethke Avatar answered Oct 20 '22 06:10

Erik Bethke


As it stands right now the only way to prevent that specific naming convention from pep8 is to disable it altogether through Settings> Inspections > Python, or simply leave as is.

like image 1
Leb Avatar answered Oct 20 '22 07:10

Leb