[pycharm] PY-80432 Fix navigation on collections.abc in imports from Typeshed to _collections_abc.py

IJ-MR-159943


(cherry picked from commit cc83e34de632c134a81c2d285b3c445ad76d2331)

IJ-MR-161809

GitOrigin-RevId: 66dca55d173d38d0a54df0c51220d0aa6bb5456d
This commit is contained in:
Mikhail Golubev
2025-04-29 16:34:22 +03:00
committed by intellij-monorepo-bot
parent 11f54723c8
commit 12609db31a
4 changed files with 20 additions and 1 deletions

View File

@@ -141,6 +141,10 @@ object PyTypeShed {
"typing.AsyncGenerator" to "_collections_abc.AsyncGenerator"
)
val typeshedModuleRedirections: Map<String, String> = mapOf(
"collections.abc" to "_collections_abc",
)
/**
* Returns true if we allow to search typeshed for a stub for [name].
*/

View File

@@ -166,10 +166,14 @@ public final class PyiUtil {
}
private static @Nullable PyFile getOriginalFile(@NotNull PyiFile file) {
final QualifiedName name = QualifiedNameFinder.findCanonicalImportPath(file, file);
QualifiedName name = QualifiedNameFinder.findCanonicalImportPath(file, file);
if (name == null) {
return null;
}
String moduleRedirect = PyTypeShed.INSTANCE.getTypeshedModuleRedirections().get(name.toString());
if (moduleRedirect != null) {
name = QualifiedName.fromDottedString(moduleRedirect);
}
final PyQualifiedNameResolveContext context = PyResolveImportUtil.fromFoothold(file).copyWithoutStubs();
return PyUtil.as(PyResolveImportUtil.resolveQualifiedName(name, context)
.stream()