Disabling and enabling inspections
Some inspections may report problems that you currently do not want to see. In this case, you can disable or suppress them.
When you disable an inspection, you turn it off. It means that the code analysis engine stops searching project files for the problem that this inspection is designed to detect. Note that when you disable an inspection, you disable it in the current inspection profile; it remains enabled in other profiles.
To partly disable an inspection for particular types of files, use the scope settings.
Disable inspections
Disable an inspection in the settings
Press Ctrl+Alt+S to open the IDE settings and select
.Locate the inspection you want to disable, and clear the checkbox next to it.
Apply the changes and close the dialog.
You can quickly disable a triggered inspection directly in the editor.
Disable an inspection in the editor
Place the caret at the highlighted line and press Alt+Enter (or click to use the intention action).
Click the arrow next to the inspection you want to disable, and select Disable inspection.
Disabling inspections in the Problems tool window
In the Inspection Results tool window (after running code analysis), right-click the inspection you want to disable and select Disable inspection.
Click to hide the disabled inspection alerts.
Re-enable inspections
Press Ctrl+Alt+S to open the IDE settings and select
.You can also press Ctrl+Alt+Shift+H and select Configure Inspections.
Locate the disabled inspection in the list and select the checkbox next to it.
Modified inspections are written in blue. You can also click and select Show Only Modified Inspections to display only the inspections with changed settings.
Click OK to apply the changes.
Suppress inspections
When you suppress an inspection, the code analysis engine doesn't highlight the problem found by this inspection in the specific piece of code (class, method, field, or statement). You can also suppress all inspections in the current class.
Suppress an inspection in the editor
Place the caret at the highlighted line and press Alt+Enter (or click to use the intention action).
Click the arrow next to the inspection you want to suppress, and select the necessary suppress action.
PyCharm adds a special comment for the corresponding piece of code.
See more noinspection comments.
Alternatively, you can use
noqa
comments to suppress individual inspections.In the comment line, you can specify flake8 error codes and pycodestyle.py error codes.
Suppress an inspection in the Inspection Results tool window
In the Inspection Results tool window (after running code analysis), right-click the inspection you want to suppress and select the necessary suppress action.
The reported problems are grouped by type, so you can evaluate and suppress all inspections of the same type.
Disable highlighting, but keep the fix
Inspections have severities according to which they highlight code problems in the editor. You can quickly disable code highlighting for an inspection without opening the settings. In this case, the inspection remains enabled and provides a fix, but the severity changes to No highlighting (fix available).
Place the caret at a code element highlighted by an inspection in the editor and press Alt+Enter.
A list with available fixes and context actions opens. Locate the inspection fix that is marked with .
Click the right arrow next to the fix to open the inspection's options and select Disable highlighting, keep fix.
The name of the inspection for which you are changing the severity is written above the inspection's options.
If you want to restore the highlighting, press Ctrl+Alt+S to open the IDE settings and select Change inspection severity in all scopes.
. Find the necessary inspection in the list and change its severity as you like. For more information, refer toChange the highlighting level for a file
By default, PyCharm highlights all detected code problems. Hover the mouse over the widget in top-right corner of the editor and select another level from the Highlight list:
None: turn highlighting off.
Syntax: highlight syntax problems only.
All Problems: (default) highlight syntax problems and problems found by inspections.
You can also change the highlighting level from the main menu. Select .
Suppressing comments
# noinspection PyPep8
# noinspection PyPep8Naming
# noinspection PyTypeChecker
# noinspection PyAbstractClass
# noinspection PyArgumentEqualDefault
# noinspection PyArgumentList
# noinspection PyAssignmentToLoopOrWithParameter
# noinspection PyAttributeOutsideInit
# noinspection PyAugmentAssignment
# noinspection PyBroadException
# noinspection PyByteLiteral
# noinspection PyCallByClass
# noinspection PyChainedComparsons
# noinspection PyClassHasNoInit
# noinspection PyClassicStyleClass
# noinspection PyComparisonWithNone
# noinspection PyCompatibility
# noinspection PyDecorator
# noinspection PyDefaultArgument
# noinspection PyDictCreation
# noinspection PyDictDuplicateKeys
# noinspection PyDocstringTypes
# noinspection PyExceptClausesOrder
# noinspection PyExceptionInheritance
# noinspection PyFromFutureImport
# noinspection PyGlobalUndefined
# noinspection PyIncorrectDocstring
# noinspection PyInitNewSignature
# noinspection PyInterpreter
# noinspection PyListCreation
# noinspection PyMandatoryEncoding
# noinspection PyMethodFirstArgAssignment
# noinspection PyMethodMayBeStatic
# noinspection PyMethodOverriding
# noinspection PyMethodParameters
# noinspection PyMissingConstructor
# noinspection PyMissingOrEmptyDocstring
# noinspection PyNestedDecorators
# noinspection PythonAsciiChar
# noinspection PyNoneFunctionAssignment
# noinspection PyOldStyleClasses
# noinspection PyPackageRequirements
# noinspection PyPropertyAccess
# noinspection PyPropertyDefinition
# noinspection PyProtectedMember
# noinspection PyRaisingNewStyleClass
# noinspection PyRedeclaration
# noinspection PyRedundantParentheses
# noinspection PySetFunctionToLiteral
# noinspection PySimplifyBooleanCheck
# noinspection PySingleQuotedDocstring
# noinspection PyStatementEffect
# noinspection PyStringException
# noinspection PyStringFormat
# noinspection PySuperArguments
# noinspection PyTrailingSemicolon
# noinspection PyTupleAssignmentBalance
# noinspection PyTupleItemAssignment
# noinspection PyUnboundLocalVariable
# noinspection PyUnnecessaryBackslash
# noinspection PyUnreachableCode
# noinspection PyUnresolvedReferences
# noinspection PyUnusedLocal
# noinspection ReturnValueFromInit
# noinspection PyAsyncCall
# noinspection PyTestParametrized
# noinspection DuplicatedCode
# noinspection SpellCheckingInspection
# noinspection PyShadowingNames