From fe61000c67d8ff355c562d2f23e56e0da5c15e01 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Wed, 22 Feb 2017 19:36:40 +0300 Subject: [PATCH] Fixed the return type of 'object.__new__' after switching to Typeshed For a while we will have it specified programmatically in our code instead of Typeshed since we don't support Type[C] yet. --- .../python/codeInsight/stdlib/PyStdlibTypeProvider.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java index ae0076690567..de5c258191fd 100644 --- a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java @@ -159,6 +159,11 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase { else if ("tuple.__mul__".equals(qname) && callSite instanceof PyBinaryExpression) { return getTupleMultiplicationResultType((PyBinaryExpression)callSite, context); } + else if ("object.__new__".equals(qname) && callSite instanceof PyCallExpression) { + final PyExpression firstArgument = ((PyCallExpression)callSite).getArgument(0, PyExpression.class); + final PyClassLikeType classLikeType = as(firstArgument != null ? context.getType(firstArgument) : null, PyClassLikeType.class); + return classLikeType != null ? Ref.create(classLikeType.toInstance()) : null; + } } return null;