State (@NotNull PsiFile file) { VirtualFile vFile = file.getVirtualFile(); if (vFile == null || !FileTypeRegistry.getInstance().isFileOfType(vFile, PythonFileType.INSTANCE)) { return null; } Sdk sdk = PythonSdkType.findLocalCPython(DocStringUtil.getModuleForElement(file)); if (sdk == null) { if (!myReportedMissingInterpreter) { myReportedMissingInterpreter = true; reportMissingInterpreter(); } return null; } final String homePath = sdk.getHomePath(); if (homePath == null) { if (!myReportedMissingInterpreter) { myReportedMissingInterpreter = true; LOG.info("Could not find home path for interpreter " + homePath); } return null; } final InspectionProfile profile = InspectionProjectProfileManager.getInstance(file.getProject()).getCurrentProfile(); final HighlightDisplayKey key = HighlightDisplayKey.find(PyPep8Inspection.INSPECTION_SHORT_NAME); if (!profile.isToolEnabled(key, file)) { return null; } if (file instanceof PyFileImpl && !((PyFileImpl)file).isAcceptedFor(PyPep8Inspection.class)) { return null; } final PyPep8Inspection inspection = (PyPep8Inspection)profile.getUnwrappedTool(PyPep8Inspection.INSPECTION_SHORT_NAME, file); final CodeStyleSettings commonSettings = CodeStyle.getSettings(file); final PyCodeStyleSettings customSettings = CodeStyle.getCustomSettings(file, PyCodeStyleSettings.class); final List<String> ignoredErrors = Lists.newArrayList(inspection.ignoredErrors); if (!customSettings.SPACE_AFTER_NUMBER_SIGN) { ignoredErrors.add("E262"); // Block comment should start with a space ignoredErrors.add("E265"); // Inline comment should start with a space } if (!customSettings.SPACE_BEFORE_NUMBER_SIGN) { ignoredErrors.add("E261"); // At least two spaces before inline comment } return new State(homePath, LanguageLevel.forElement(file), file.getText(), profile.getErrorLevel(key, file), ignoredErrors, commonSettings.getRightMargin(PythonLanguage.getInstance()), customSettings.HANG_CLOSING_BRACKETS); }