From 00c78ebb84e6426899f76c974b7144ae3e15b574 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Wed, 30 Apr 2025 11:10:02 +0300 Subject: [PATCH] [python] Don't treat PyClassLikeType as PyCallableType in PyTypeVisitor by default GitOrigin-RevId: 647848f03c4816fb96a6bfcfcad6d9c7258a57ea --- .../com/jetbrains/python/psi/types/PyTypeVisitor.java | 3 ++- .../python/psi/types/PyRecursiveTypeVisitor.java | 9 --------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/python/python-psi-api/src/com/jetbrains/python/psi/types/PyTypeVisitor.java b/python/python-psi-api/src/com/jetbrains/python/psi/types/PyTypeVisitor.java index 0526c4292fed..0a74502a3a78 100644 --- a/python/python-psi-api/src/com/jetbrains/python/psi/types/PyTypeVisitor.java +++ b/python/python-psi-api/src/com/jetbrains/python/psi/types/PyTypeVisitor.java @@ -43,7 +43,8 @@ public abstract class PyTypeVisitor { } public T visitPyClassLikeType(@NotNull PyClassLikeType classLikeType) { - return visitPyCallableType(classLikeType); + // Don't treat PyClassLikeType as PyCallableType. It's usually not what a visitor's user expects. + return visitPyType(classLikeType); } public T visitPyFunctionType(@NotNull PyFunctionType functionType) { diff --git a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyRecursiveTypeVisitor.java b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyRecursiveTypeVisitor.java index f8f1091d694c..3270560b87ee 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyRecursiveTypeVisitor.java +++ b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyRecursiveTypeVisitor.java @@ -140,15 +140,6 @@ public final class PyRecursiveTypeVisitor extends PyTypeVisitorExt visitPyClassLikeType(@NotNull PyClassLikeType classLikeType) { - // Don't inherit the default implementation from PyCallableType. - // Even though PyClassLikeType can behave like a callable if the corresponding class - // has __init__ or __call__, most likely the respective parameter types and - // return type are not part of its notation. - return Collections.emptyList(); - } - @Override public @NotNull List<@Nullable PyType> visitPyGenericType(@NotNull PyCollectionType genericType) { return genericType.getElementTypes();