PY-24637 Use non-resolvable built-in constants check for doctest and Jupyter references

Since the switch to the builtins from Typeshed we no longer have
the definitions for True, False, None for PY2. We have to ignore these
references via null highlighting severity as we do in the base method
for PyReferenceImpl.
This commit is contained in:
Andrey Vlasovskikh
2017-08-30 23:19:24 +03:00
parent f54be8708d
commit cb22683f8d
4 changed files with 14 additions and 2 deletions
@@ -25,7 +25,8 @@ public class IpnbPyReference extends PyReferenceImpl {
@Override
public HighlightSeverity getUnresolvedHighlightSeverity(TypeEvalContext context) {
return HighlightSeverity.WARNING;
final HighlightSeverity severity = super.getUnresolvedHighlightSeverity(context);
return severity != null ? HighlightSeverity.WARNING : null;
}
@NotNull
@@ -51,7 +51,8 @@ public class PyDocReference extends PyReferenceImpl {
@Override
public HighlightSeverity getUnresolvedHighlightSeverity(TypeEvalContext context) {
return HighlightSeverity.WARNING;
final HighlightSeverity severity = super.getUnresolvedHighlightSeverity(context);
return severity != null ? HighlightSeverity.WARNING : null;
}
@NotNull
@@ -0,0 +1,5 @@
def func(x, y):
"""
>>> func(True, <warning descr="Unresolved reference 'True2'">True2</warning>)
"""
return True, <error descr="Unresolved reference 'True2'">True2</error>
@@ -637,6 +637,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
doMultiFileTest();
}
// PY-24637
public void testPy2TrueInDocTest() {
doTest();
}
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {