Skip to content

Commit 231fd3c

Browse files
author
Steven Silvester
authored
Merge pull request #787 from JohanMabille/richInspect
Enabled rich rendering of variables in the debugger
2 parents 63e904e + 37c6846 commit 231fd3c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

ipykernel/debugger.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ async def debugInfo(self, message):
493493
'tmpFilePrefix': get_tmp_directory() + '/',
494494
'tmpFileSuffix': '.py',
495495
'breakpoints': breakpoint_list,
496-
'stoppedThreads': self.stopped_threads
496+
'stoppedThreads': self.stopped_threads,
497+
'richRendering': True
497498
}
498499
}
499500
return reply
@@ -509,7 +510,24 @@ async def inspectVariables(self, message):
509510
return self._build_variables_response(message, variables)
510511

511512
async def richInspectVariables(self, message):
513+
reply = {
514+
'type': 'response',
515+
'sequence_seq': message['seq'],
516+
'success': False,
517+
'command': message['command']
518+
}
519+
512520
var_name = message['arguments']['variableName']
521+
valid_name = str.isidentifier(var_name)
522+
if not valid_name:
523+
reply['body'] = {
524+
'data': {},
525+
'metadata': {}
526+
}
527+
if var_name == 'special variables' or var_name == 'function variables':
528+
reply['success'] = True
529+
return reply
530+
513531
var_repr_data = var_name + '_repr_data'
514532
var_repr_metadata = var_name + '_repr_metadata'
515533

@@ -536,13 +554,6 @@ async def richInspectVariables(self, message):
536554
}
537555
await self._forward_message(request)
538556

539-
reply = {
540-
'type': 'response',
541-
'sequence_seq': message['seq'],
542-
'success': False,
543-
'command': message['command']
544-
}
545-
546557
repr_data = globals()[var_repr_data]
547558
repr_metadata = globals()[var_repr_metadata]
548559
body = {

0 commit comments

Comments
 (0)