NumpyResolveRater will not change member rate if NDARRAY type is not found

This commit is contained in:
Semyon Proshev
2016-12-01 15:19:00 +03:00
parent dc730e866d
commit 42c6c1be3e
2 changed files with 13 additions and 2 deletions
@@ -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;
}
@@ -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);