boolean (@NotNull VirtualFile vFile, @Nullable Sdk pythonSdk) { if (pythonSdk != null) { @Nullable VirtualFile originFile = vFile; @NotNull String originPath = vFile.getPath(); boolean checkOnRemoteFS = false; // All binary skeletons are collected under the same root regardless of their original location. // Because of that we need to use paths to the corresponding binary modules recorded in their headers. final PySkeletonHeader header = readSkeletonHeader(originFile, pythonSdk); if (header != null) { // Binary module paths in skeleton headers of Mock SDK don't map to actual physical files. // Fallback to the old heuristic for these stubs. if (ApplicationManager.getApplication().isUnitTestMode() && Objects.equals(vFile.getParent(), findSkeletonsDir(pythonSdk))) { return true; } final String binaryPath = header.getBinaryFile(); // XXX Assume that all pre-generated stubs belong to the interpreter's stdlib -- might change in future with PY-32229 if (binaryPath.equals(PySkeletonHeader.BUILTIN_NAME) || binaryPath.equals(PySkeletonHeader.PREGENERATED)) { return true; } if (isRemote(pythonSdk)) { checkOnRemoteFS = true; // Actual file is on remote file system and not available originFile = null; } else { originFile = VfsUtil.findFileByIoFile(new File(binaryPath), true); } originPath = binaryPath; } if (originFile != null) { originFile = ObjectUtils.notNull(originFile.getCanonicalFile(), originFile); originPath = originFile.getPath(); } final VirtualFile libDir = PySearchUtilBase.findLibDir(pythonSdk); if (libDir != null && isUnderLibDirButNotSitePackages(originFile, originPath, libDir, pythonSdk, checkOnRemoteFS)) { return true; } final VirtualFile venvLibDir = PySearchUtilBase.findVirtualEnvLibDir(pythonSdk); if (venvLibDir != null && isUnderLibDirButNotSitePackages(originFile, originPath, venvLibDir, pythonSdk, checkOnRemoteFS)) { return true; } if (PyUserSkeletonsUtil.isStandardLibrarySkeleton(vFile)) { return true; } if (PyTypeShed.INSTANCE.isInStandardLibrary(vFile) && PyTypeShed.INSTANCE.isInside(vFile)) { return true; } } return false; }