mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-24960 Fixed: False-positive warning about results of comparison operators for imported types
Don't ignore unknown and none types as operator call types.
This commit is contained in:
@@ -166,11 +166,9 @@ public class PyBinaryExpressionImpl extends PyElementImpl implements PyBinaryExp
|
||||
}
|
||||
}
|
||||
final PyType type = markedCallee.getCallableType().getCallType(context, this);
|
||||
if (!PyTypeChecker.isUnknown(type, context) && !(type instanceof PyNoneType)) {
|
||||
types.add(type);
|
||||
if (matched) {
|
||||
matchedTypes.add(type);
|
||||
}
|
||||
types.add(type);
|
||||
if (matched) {
|
||||
matchedTypes.add(type);
|
||||
}
|
||||
}
|
||||
final boolean bothOperandsAreKnown = operandIsKnown(getLeftExpression(), context) && operandIsKnown(getRightExpression(), context);
|
||||
|
||||
@@ -2263,6 +2263,19 @@ public class PyTypeTest extends PyTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
// PY-24960
|
||||
public void testOperatorReturnsAny() {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.PYTHON35,
|
||||
() -> doTest("Union[bool, Any]",
|
||||
"from typing import Any\n" +
|
||||
"class Bar:\n" +
|
||||
" def __eq__(self, other) -> Any:\n" +
|
||||
" pass\n" +
|
||||
"expr = (Bar() == 2)")
|
||||
);
|
||||
}
|
||||
|
||||
private static List<TypeEvalContext> getTypeEvalContexts(@NotNull PyExpression element) {
|
||||
return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(),
|
||||
TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());
|
||||
|
||||
Reference in New Issue
Block a user