PsiElement (@Nullable PsiElement target) { if (target instanceof PsiDirectory dir) { final PsiFile initStub = dir.findFile(PyNames.INIT_DOT_PYI); if (initStub != null && !PyiStubSuppressor.isIgnoredStub(initStub)) { return initStub; } final PsiFile initFile = dir.findFile(PyNames.INIT_DOT_PY); if (initFile != null) { return initFile; // ResolveImportUtil will extract directory part as needed, everyone else are better off with a file. } else { return null; } // dir without __init__.py does not resolve } else { return target; } // don't touch non-dirs }