pythonpycharminspection

PyCharm is not doing code inspection on non-project files


I'm working on a Python project in PyCharm and I wanted to edit a python script outside the project. PyCharm doesn't inspect the code and doesn't give any PEP8 violations. Hoped that there would be a setting for that but couldn't find anything so far.

Does anyone know how to enable code inspection on non-project files in PyCharm?

enter image description here


Solution

  • I am able to reproduce the problem (with 5.0.5 Pro Linux version).

    The inspection is actually active and the PEP8 checks are all enabled, I even got a blank line at end of file flag raised, but not an unresolved reference one:

    enter image description here

    Looks like Arnaud P may be right, as the exact same file content in a project file raises the unresolved reference flags:

    I suppose Pycharm considers it doesn't know enough to complain about unresolved variables, since this file might be part of another project. – Arnaud P 22 mins ago

    Confirmed by JetBrains:

    This is the answer I've got from them: "This is expected behavior, this inspection is suspended if file is outside of current project. PyCharm doesn't know configuration, source roots, etc of other projects/other files." So I mark your suggestion as the accepted answer. – Sinan Çetinkaya 5 mins ago

    As a workaround you could have a (re-usable) project with one (or more) files in which you paste non-project file contents just for the purpose of running inspections.

    Or just create a project for that file.