diff --git a/python/src/com/jetbrains/python/codeInsight/stdlib/PyNamedTupleType.java b/python/src/com/jetbrains/python/codeInsight/stdlib/PyNamedTupleType.java index 431b8b369bdc..384925c8a8a7 100644 --- a/python/src/com/jetbrains/python/codeInsight/stdlib/PyNamedTupleType.java +++ b/python/src/com/jetbrains/python/codeInsight/stdlib/PyNamedTupleType.java @@ -29,7 +29,7 @@ public class PyNamedTupleType extends PyClassType implements PyCallableType { private final boolean myDefinition; private final PsiElement myDeclaration; private final List myFields; - + private static final ImmutableSet ourClassMembers = ImmutableSet.of("_fields", "_make"); private static final ImmutableSet ourInstanceMembers = ImmutableSet.of("_asdict", "_replace"); @@ -83,7 +83,7 @@ public class PyNamedTupleType extends PyClassType implements PyCallableType { @Override public String getName() { - return "namedtuple '" + myName + "'"; + return myName; } @Override @@ -99,6 +99,16 @@ public class PyNamedTupleType extends PyClassType implements PyCallableType { return null; } + @Override + public PyClassType toInstance() { + return myIsDefinition ? new PyNamedTupleType(myDeclaration, myName, myFields, false) : this; + } + + @Override + public String toString() { + return "PyNamedTupleType: " + myName; + } + @Nullable public static PyType fromCall(PyCallExpression call) { final String name = PyUtil.strValue(call.getArgument(0, PyExpression.class)); diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/namedTuple.py b/python/testData/inspections/PyUnresolvedReferencesInspection/namedTuple.py index 6be5439959d5..66b7904a60a3 100644 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/namedTuple.py +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/namedTuple.py @@ -10,3 +10,6 @@ print p.__add__ print p._asdict() print Point._fields print p._replace + +if isinstance(p, Point): + p.x \ No newline at end of file