@NotNull
  private static GlobalSearchScope createScope(@NotNull PsiFile originalFile) {
    class HavingLegalImportPathScope extends QualifiedNameFinder.QualifiedNameBasedScope {
      private HavingLegalImportPathScope(@NotNull Project project) {
        super(project);
      }

      @Override
      protected boolean containsQualifiedNameInRoot(@NotNull VirtualFile root, @NotNull QualifiedName qName) {
        return ContainerUtil.all(qName.getComponents(), PyNames::isIdentifier) && !qName.equals(QualifiedName.fromComponents("__future__"));
      }
    }

    Project project = originalFile.getProject();
    var pyiStubsScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.everythingScope(project), PyiFileType.INSTANCE);
    return PySearchUtilBase.defaultSuggestionScope(originalFile)
      .intersectWith(GlobalSearchScope.notScope(pyiStubsScope))
      .intersectWith(GlobalSearchScope.notScope(GlobalSearchScope.fileScope(originalFile)))
      .intersectWith(new HavingLegalImportPathScope(project));
  }
@NotNull
  private static GlobalSearchScope createScope(@NotNull PsiFile originalFile)