int (@NotNull PyExpression assignedValue, @NotNull TypeEvalContext context) { if (assignedValue instanceof PySequenceExpression) { return ((PySequenceExpression)assignedValue).getElements().length; } else if (assignedValue instanceof PyStringLiteralExpression) { return ((PyStringLiteralExpression)assignedValue).getStringValue().length(); } else if (assignedValue instanceof PyNumericLiteralExpression || assignedValue instanceof PyNoneLiteralExpression) { return 1; } else if (assignedValue instanceof PyCallExpression call) { if (call.isCalleeText("dict")) { return call.getArguments().length; } else if (call.isCalleeText("tuple")) { final PyExpression firstArgument = ArrayUtil.getFirstElement(call.getArguments()); if (firstArgument instanceof PySequenceExpression) { return ((PySequenceExpression)firstArgument).getElements().length; } } } final PyType assignedType = context.getType(assignedValue); if (assignedType instanceof PyTupleType) { return ((PyTupleType)assignedType).getElementCount(); } else if (assignedType instanceof PyNoneType) { return 1; } return -1; }