in recent jupyter notebooks there is support for experimental metadata in completions.
I've worked around it implementing this in base kernel:
private void handleCompleteRequest(ShellReplyEnvironment env, Message<CompleteRequest> completeRequestMessage) {
CompleteRequest request = (CompleteRequest)completeRequestMessage.getContent();
env.setBusyDeferIdle();
try {
ReplacementOptions options = this.complete(request.getCode(), request.getCursorPos());
if (options == null) {
env.reply(new CompleteReply(Collections.emptyList(), request.getCursorPos(), request.getCursorPos(), Collections.emptyMap()));
} else {
// adjust the completions to include the experimental types
// for nicer combobox rendering
Map<String, Object> metadata = new HashMap<>();
List<JupyterExperimentalType> experimentalTypes = new ArrayList<>();
// List<JupyterExtendedMetadataEntry> extendedMetadata = new ArrayList<>();
options.getReplacements().forEach(replacement -> {
String type = "code";
// poor man type detection
if(replacement.startsWith("%")) {
type = "magic";
} else if(replacement.endsWith("(") || replacement.endsWith("()")) {
type = "function";
}
experimentalTypes.add(new JupyterExperimentalType(replacement, type, options.getSourceStart(), options.getSourceEnd()));
// metadata.put("experimental", experimentalTypes);
});
metadata.put("_jupyter_types_experimental", experimentalTypes);
env.reply(new CompleteReply(options.getReplacements(), options.getSourceStart(), options.getSourceEnd(), metadata));
}
} catch (Exception var5) {
env.replyError(CompleteReply.MESSAGE_TYPE.error(), ErrorReply.of(var5));
}
}
to give this result:
i can submit pr for the above but i think it makes more sense that the type part is part of the ReplacementOptions but didnt want to do that before getting some feedback.
in recent jupyter notebooks there is support for experimental metadata in completions.
I've worked around it implementing this in base kernel:
to give this result:
i can submit pr for the above but i think it makes more sense that the type part is part of the ReplacementOptions but didnt want to do that before getting some feedback.