Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pylover
Forked from ar45/inspections.txt
Last active April 22, 2024 07:47
Show Gist options
  • Save pylover/7870c235867cf22817ac5b096defb768 to your computer and use it in GitHub Desktop.
Save pylover/7870c235867cf22817ac5b096defb768 to your computer and use it in GitHub Desktop.
PyCharm inspections
# Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |'
# 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 PynonAsciiChar
# 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 SpellCheckingInspection
# noinspection PyShadowingNames
# noinspection PyCallingNonCallable
@jeffsilverm
Copy link

I'm having the devil's time finding where this list is documented. A clue, please?

@gshefer
Copy link

gshefer commented Oct 23, 2018

Adding myself to the question above...

@carlomazzaferro
Copy link

Thanks for putting this up, amazingly helpful

@mdegans
Copy link

mdegans commented Feb 14, 2019

Thanks for this list!

@Yelizar
Copy link

Yelizar commented May 28, 2019

Thanks!!!

@wuye9036
Copy link

Thank you so much for this list!

@pylover
Copy link
Author

pylover commented Sep 27, 2019

There is no official documentation is available, The list above is extracted from Pycharm's binary.

You may re-run the command at the first line of the script to regenerate this list again.

@carolineye
Copy link

carolineye commented Dec 12, 2019

@pedramkabir
Copy link

hi
what is this?

@HiImJulien
Copy link

@pedramkabir It's a list of all builtin warnings, that PyCharm provides when inspecting your code.
With the line # noinspection PyBroadException you can suppress the warning for specific line.

E.g.:

try:
    do_something_that_may_raise_an_exception()
except Exception as e: # Here PyCharm tells you that this is no bueno
    do_something_to_handle_it()

but with the list above you can tell PyCharm, that you don't give a damn about the warning:

try:
    do_something_that_may_raise_an_exception()
# noinspection PyBroadException
except Exception as e:
    do_something_to_handle_it()

@banagale
Copy link

Note, # noinspection PyUnusedLocal corresponds to the inspection warning: "Parameter [param] value is not used"

@AliGhahraei
Copy link

Thank you for this! However, we can now use # noqa as well:

https://youtrack.jetbrains.com/issue/PY-8656
https://blog.jetbrains.com/pycharm/2020/02/pycharm-2020-1-eap-4/

I tried today and it works in 2020.2.1 (Professional Edition).

@banagale
Copy link

banagale commented Sep 16, 2020

@AliGhahraei thanks for posting this, I did not realize this was added. The #noinspection behavior wasn’t enough.

It made it harder than it should have been to easily leverage inspections across the project or at a commit. Hunting for case-specific comments to was no fun. It seemed like they sometimes not be offered by the context menu or be buried unintuitively.

I mean that’s why so many people have ended up here right.

Ultimately they clutter the code.

Some of the most bothersome to me recently have been false positive inspections in DRF like in a Serializer.

I think Scopes could still use a lot of work, the UX is still kinda funky and just needs more polishing.

@pedramkabir
Copy link

@pedramkabir It's a list of all builtin warnings, that PyCharm provides when inspecting your code.
With the line # noinspection PyBroadException you can suppress the warning for specific line.

E.g.:

try:
    do_something_that_may_raise_an_exception()
except Exception as e: # Here PyCharm tells you that this is no bueno
    do_something_to_handle_it()

but with the list above you can tell PyCharm, that you don't give a damn about the warning:

try:
    do_something_that_may_raise_an_exception()
# noinspection PyBroadException
except Exception as e:
    do_something_to_handle_it()

thank you sir
it was helpful

@iotanbo
Copy link

iotanbo commented Dec 14, 2020

As on December 14th 2020, some warnings, e.g. PyShadowingBuiltins are not included. Luckily, official documentation now describes how you can do it. To suppress a particular inspection in PyCharm, place cursor at the problematic word, then press 'Alt+Enter' and wait context help to pop up. Press 'More actions', then small triangle at the right of 'Ignore ... ' line. Finally choose suppression type, e.g. 'Suppress for function'. Alternatively, you can place a # noqa comment at the end of problematic line as mentioned by AliGhahraei.

@rpgoldman
Copy link

@iotanbo Alas, there appear to be some inspections for which one is not offered this option. I have a stub class that has a method for __init__ that overrides the parent class's, not calling the super method. PyCharm does not offer the option to suppress this warning.

@banagale
Copy link

banagale commented Feb 9, 2021

@rpgoldman There are definitely major gaps in Pycharm's warning vs recommended changes and suppression statements for specific inspections.

I have used the #noqa end-of-line remark @iotanbo mentioned where there are no obvious ways to squelch a warning. Have you tried this?

@rpgoldman
Copy link

@banagale Yes, I was able to get that to work, thanks.

@daveusa31
Copy link

Please add it to ignore spelling errors.
# noinspection SpellCheckingInspection

@pylover
Copy link
Author

pylover commented Apr 13, 2021

@daveusa31, done.

@gherolyants
Copy link

Please, add this to ignore shadowing warnings:

# noinspection PyShadowingNames

@pylover
Copy link
Author

pylover commented Sep 14, 2021

@gherolyants, done.

@jwshieldsGetty
Copy link

I just want to add to this.
Regarding the "Broad Exception" - I am running 2021.3.2 CE, also tested in 2022.1 EAP build 221.3427.103;

When using a try/except with # noinspection PyBroadException - the comment must be at the top of the try portion.
IE:
Good:

# noinspection PyBroadException
try:
    print("Thing to try")
except Exception:
    print("Exception!)

Bad:

try:
    print("Thing to try")
# noinspection PyBroadException
except Exception:
    print("Exception!)

@s4ly
Copy link

s4ly commented Aug 16, 2022

please, add # noinspection PyCallingNonCallable

@jmugan
Copy link

jmugan commented Oct 5, 2023

Note that # noinspection PyUnresolvedReferences works for ignoring unused imports.

@pylover
Copy link
Author

pylover commented Oct 6, 2023

Good to know, but contact JetBrains for such kind of issues.

@ToolBoxSystems
Copy link

A very useful list of all #noinspection comments is here:
https://www.jetbrains.com/help/pycharm/disabling-and-enabling-inspections.html#comments-ref

Also, other useful PyCharm info about suppressing comments is here:
https://www.jetbrains.com/help/pycharm/disabling-and-enabling-inspections.html#suppressing-comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment