PY-18744 Don't advertise compatibility inspection in library sources
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Wed, 24 Aug 2016 11:39:44 +0000 (14:39 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Thu, 25 Aug 2016 12:07:13 +0000 (15:07 +0300)
In particular, if some library imports __future__ or six, it doesn't
necessarily mean that project which uses it is intended to be
cross-compatible as well.

python/src/com/jetbrains/python/inspections/PyCompatibilityInspectionAdvertiser.java

index 53c5e9250ca0aa961c769215d7857e3fa39b47b9..7288228579b33bd5298df3ebf6df273e0315dbc8 100644 (file)
@@ -31,9 +31,11 @@ import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleUtilCore;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.FileIndexFacade;
 import com.intellij.openapi.util.JDOMExternalizableStringList;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.util.QualifiedName;
@@ -77,6 +79,11 @@ public class PyCompatibilityInspectionAdvertiser implements Annotator {
 
       final PyFile pyFile = (PyFile)element;
       final Project project = element.getProject();
+
+      final VirtualFile vFile = pyFile.getVirtualFile();
+      if (vFile != null && FileIndexFacade.getInstance(project).isInLibraryClasses(vFile)) {
+        return;
+      }
       
       final Boolean showingFlag = project.getUserData(DONT_SHOW_BALLOON);
       if (showingFlag != null && showingFlag.booleanValue()) {