mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-20057 Render the type of "type" class as just "type" instead of "Type[type]"
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider;
|
||||
import com.jetbrains.python.psi.impl.PyBuiltinCache;
|
||||
import com.jetbrains.python.psi.types.*;
|
||||
import com.jetbrains.python.toolbox.ChainIterable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -280,7 +281,14 @@ public class PyTypeModelBuilder {
|
||||
result = buildCallable((PyCallableType)type);
|
||||
}
|
||||
else if (type instanceof PyInstantiableType && ((PyInstantiableType)type).isDefinition()) {
|
||||
result = new ClassObjectType(build(((PyInstantiableType)type).toInstance(), allowUnions));
|
||||
final PyInstantiableType instanceType = ((PyInstantiableType)type).toInstance();
|
||||
// Special case: render Type[type] as just type
|
||||
if (type instanceof PyClassType && instanceType.equals(PyBuiltinCache.getInstance(((PyClassType)type).getPyClass()).getTypeType())) {
|
||||
result = NamedType.nameOrAny(type);
|
||||
}
|
||||
else {
|
||||
result = new ClassObjectType(build(instanceType, allowUnions));
|
||||
}
|
||||
}
|
||||
else if (type instanceof PyGenericType) {
|
||||
//assert !((PyGenericType)type).isDefinition()
|
||||
|
||||
+2
-2
@@ -32,9 +32,9 @@ expects_type(type)
|
||||
expects_type(object)
|
||||
expects_typing_type(type)
|
||||
expects_typing_type(object)
|
||||
expects_str_class(<warning descr="Expected type 'Type[str]', got 'Type[type]' instead">type</warning>)
|
||||
expects_str_class(<warning descr="Expected type 'Type[str]', got 'type' instead">type</warning>)
|
||||
expects_any_type_via_type_var(type)
|
||||
expects_str_subclass(<warning descr="Expected type 'Type[TypeVar('T', str)]', got 'Type[type]' instead">type</warning>)
|
||||
expects_str_subclass(<warning descr="Expected type 'Type[TypeVar('T', str)]', got 'type' instead">type</warning>)
|
||||
expects_object(type)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user