From 42c6c1be3e445b743a2126669d03ed143753eaf4 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Thu, 1 Dec 2016 14:38:11 +0300 Subject: [PATCH] NumpyResolveRater will not change member rate if NDARRAY type is not found --- .../numpy/codeInsight/NumpyResolveRater.java | 4 ++-- python/testSrc/com/jetbrains/python/Py3TypeTest.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/python/src/com/jetbrains/numpy/codeInsight/NumpyResolveRater.java b/python/src/com/jetbrains/numpy/codeInsight/NumpyResolveRater.java index 304e9e77c9c1..1ab734ab0dde 100644 --- a/python/src/com/jetbrains/numpy/codeInsight/NumpyResolveRater.java +++ b/python/src/com/jetbrains/numpy/codeInsight/NumpyResolveRater.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public class NumpyResolveRater extends PyResolveResultRaterBase { public int getMemberRate(PsiElement member, PyType type, TypeEvalContext context) { if (member instanceof PsiNamedElement) { final PyType ndArray = PyTypeParser.getTypeByName(member, NumpyDocStringTypeProvider.NDARRAY); - if (PyTypeChecker.match(ndArray, type, context) && + if (ndArray != null && PyTypeChecker.match(ndArray, type, context) && PyNames.isRightOperatorName(((PsiNamedElement)member).getName())) { return 100; } diff --git a/python/testSrc/com/jetbrains/python/Py3TypeTest.java b/python/testSrc/com/jetbrains/python/Py3TypeTest.java index 43eeaa028607..4f769a35c3db 100644 --- a/python/testSrc/com/jetbrains/python/Py3TypeTest.java +++ b/python/testSrc/com/jetbrains/python/Py3TypeTest.java @@ -481,6 +481,17 @@ public class Py3TypeTest extends PyTestCase { "expr = sum([1, 2, 3])"); } + public void testDecimalDividedByInt() { + doTest("Union[int, Decimal]", + "class Decimal(object):\n" + + " def __div__(self, other):\n" + + " \"\"\"\n" + + " :rtype: Decimal" + + " \"\"\"\n" + + " pass\n" + + "expr = Decimal() / 5"); + } + private void doTest(final String expectedType, final String text) { myFixture.configureByText(PythonFileType.INSTANCE, text); final PyExpression expr = myFixture.findElementByText("expr", PyExpression.class);