mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NumpyResolveRater will not change member rate if NDARRAY type is not found
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user