File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Add exclude list to variable viewer
Original file line number Diff line number Diff line change 13881388 "description" : " Show the variable explorer in the Python Interactive window. (experimental)" ,
13891389 "scope" : " resource"
13901390 },
1391+ "python.dataScience.variableExplorerExclude" : {
1392+ "type" : " string" ,
1393+ "default" : " module;builtin_function_or_method" ,
1394+ "description" : " Types to exclude from showing in the Python Interactive variable explorer" ,
1395+ "scope" : " resource"
1396+ },
13911397 "python.dataScience.codeRegularExpression" : {
13921398 "type" : " string" ,
13931399 "default" : " ^(#\\ s*%%|#\\ s*\\ <codecell\\ >|#\\ s*In\\ [\\ d*?\\ ]|#\\ s*In\\ [ \\ ])" ,
Original file line number Diff line number Diff line change 11# Query Jupyter server for defined variables list
22# Tested on 2.7 and 3.6
3- from sys import getsizeof
3+ from sys import getsizeof as _VSCODE_getsizeof
44import json as _VSCODE_json
55
66# who_ls is a Jupyter line magic to fetch currently defined vars
77_VSCode_JupyterVars = % who_ls
88
99print (_VSCODE_json .dumps ([{'name' : var ,
1010 'type' : type (eval (var )).__name__ ,
11- 'size' : getsizeof (var ),
11+ 'size' : _VSCODE_getsizeof (var ),
1212 'expensive' : True
1313 } for var in _VSCode_JupyterVars ]))
14+
15+ del _VSCode_JupyterVars
16+ del _VSCODE_json
17+ del _VSCODE_getsizeof
Original file line number Diff line number Diff line change 2222else :
2323 _VSCODE_targetVariable ['value' ] = _VSCODE_targetValue
2424
25- print (_VSCODE_json .dumps (_VSCODE_targetVariable ))
25+ print (_VSCODE_json .dumps (_VSCODE_targetVariable ))
26+
27+ # Cleanup
28+ del _VSCODE_max_len
29+ del _VSCODE_json
30+ del _VSCODE_targetVariable
31+ del _VSCODE_evalResult
32+ del _VSCODE_targetValue
Original file line number Diff line number Diff line change @@ -303,6 +303,7 @@ export interface IDataScienceSettings {
303303 errorBackgroundColor : string ;
304304 ignoreVscodeTheme ?: boolean ;
305305 showJupyterVariableExplorer ?: boolean ;
306+ variableExplorerExclude ?: string ;
306307}
307308
308309export const IConfigurationService = Symbol ( 'IConfigurationService' ) ;
Original file line number Diff line number Diff line change @@ -920,7 +920,18 @@ export class History extends WebViewHost<IHistoryMapping> implements IHistory {
920920
921921 private requestVariables = async ( ) : Promise < void > => {
922922 // Request our new list of variables
923- const vars : IJupyterVariable [ ] = await this . jupyterVariables . getVariables ( ) ;
923+ let vars : IJupyterVariable [ ] = await this . jupyterVariables . getVariables ( ) ;
924+
925+ const settings = this . configuration . getSettings ( ) ;
926+ const excludeString = settings . datascience . variableExplorerExclude ;
927+
928+ if ( excludeString ) {
929+ const excludeArray = excludeString . split ( ';' ) ;
930+ vars = vars . filter ( ( value ) => {
931+ return excludeArray . indexOf ( value . type ) === - 1 ;
932+ } ) ;
933+ }
934+
924935 this . postMessage ( HistoryMessages . GetVariablesResponse , vars ) . ignoreErrors ( ) ;
925936 }
926937
You can’t perform that action at this time.
0 commit comments