File tree Expand file tree Collapse file tree 4 files changed +170
-9
lines changed Expand file tree Collapse file tree 4 files changed +170
-9
lines changed Original file line number Diff line number Diff line change 1
1
const cp = require ( "child_process" ) ;
2
2
const { shell } = require ( "electron" ) ;
3
3
const { AutoLanguageClient } = require ( "atom-languageclient" ) ;
4
- const { detectVirtualEnv } = require ( "./utils" ) ;
4
+ const { detectVirtualEnv, sanitizeConfig } = require ( "./utils" ) ;
5
5
6
6
// Ref: https://github.com/nteract/hydrogen/blob/master/lib/autocomplete-provider.js#L33
7
7
// adapted from http://stackoverflow.com/q/5474008
@@ -34,7 +34,7 @@ class PythonLanguageClient extends AutoLanguageClient {
34
34
return {
35
35
pyls : {
36
36
configurationSources : configuration . pylsConfigurationSources ,
37
- rope : { ropeFolder : configuration . ropeFolder !== "null" ? configuration . ropeFolder : null } ,
37
+ rope : sanitizeConfig ( configuration . rope ) ,
38
38
plugins : configuration . pylsPlugins
39
39
}
40
40
} ;
Original file line number Diff line number Diff line change @@ -42,4 +42,14 @@ async function detectVirtualEnv(path) {
42
42
}
43
43
}
44
44
45
+ function sanitizeConfig ( config ) {
46
+ Object . entries ( config ) . forEach ( ( [ key , value ] ) => {
47
+ if ( value === "null" ) {
48
+ config [ key ] = null ;
49
+ }
50
+ } ) ;
51
+ return config ;
52
+ }
53
+
45
54
exports . detectVirtualEnv = detectVirtualEnv ;
55
+ exports . sanitizeConfig = sanitizeConfig ;
Original file line number Diff line number Diff line change 55
55
]
56
56
}
57
57
},
58
- "ropeFolder" : {
59
- "order" : 3 ,
60
- "type" : " string" ,
61
- "default" : " .ropeproject" ,
62
- "description" : " The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all."
63
- },
64
58
"pylsPlugins" : {
65
59
"title" : " Python Language Server Plugins" ,
66
60
"type" : " object" ,
61
+ "order" : 3 ,
67
62
"properties" : {
68
63
"jedi_completion" : {
69
64
"title" : " Jedi Completion" ,
162
157
}
163
158
}
164
159
},
160
+ "preload" : {
161
+ "title" : " Preload" ,
162
+ "type" : " object" ,
163
+ "properties" : {
164
+ "enabled" : {
165
+ "title" : " Enabled" ,
166
+ "type" : " boolean" ,
167
+ "default" : true ,
168
+ "description" : " Enable or disable preload."
169
+ },
170
+ "modules" : {
171
+ "title" : " Modules" ,
172
+ "type" : " array" ,
173
+ "default" : [
174
+ " OpenGL" ,
175
+ " PIL" ,
176
+ " array" ,
177
+ " audioop" ,
178
+ " binascii" ,
179
+ " cPickle" ,
180
+ " cStringIO" ,
181
+ " cmath" ,
182
+ " collections" ,
183
+ " datetime" ,
184
+ " errno" ,
185
+ " exceptions" ,
186
+ " gc" ,
187
+ " imageop" ,
188
+ " imp" ,
189
+ " itertools" ,
190
+ " marshal" ,
191
+ " math" ,
192
+ " matplotlib" ,
193
+ " mmap" ,
194
+ " mpmath" ,
195
+ " msvcrt" ,
196
+ " networkx" ,
197
+ " nose" ,
198
+ " nt" ,
199
+ " numpy" ,
200
+ " operator" ,
201
+ " os" ,
202
+ " os.path" ,
203
+ " pandas" ,
204
+ " parser" ,
205
+ " rgbimg" ,
206
+ " scipy" ,
207
+ " signal" ,
208
+ " skimage" ,
209
+ " sklearn" ,
210
+ " statsmodels" ,
211
+ " strop" ,
212
+ " sympy" ,
213
+ " sys" ,
214
+ " thread" ,
215
+ " time" ,
216
+ " wx" ,
217
+ " xxsubtype" ,
218
+ " zipimport" ,
219
+ " zlib"
220
+ ],
221
+ "items" : {
222
+ "type" : " string"
223
+ },
224
+ "description" : " List of modules to import on startup"
225
+ }
226
+ }
227
+ },
165
228
"pycodestyle" : {
166
229
"title" : " PyCodeStyle" ,
167
230
"type" : " object" ,
345
408
}
346
409
}
347
410
}
411
+ },
412
+ "rope" : {
413
+ "type" : " object" ,
414
+ "properties" : {
415
+ "ropeFolder" : {
416
+ "title" : " Rope Folder" ,
417
+ "type" : " string" ,
418
+ "default" : " .ropeproject" ,
419
+ "description" : " The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all."
420
+ },
421
+ "extensionModules" : {
422
+ "title" : " Extension Modules" ,
423
+ "type" : " array" ,
424
+ "default" : [
425
+ " OpenGL" ,
426
+ " PIL" ,
427
+ " array" ,
428
+ " audioop" ,
429
+ " binascii" ,
430
+ " cPickle" ,
431
+ " cStringIO" ,
432
+ " cmath" ,
433
+ " collections" ,
434
+ " datetime" ,
435
+ " errno" ,
436
+ " exceptions" ,
437
+ " gc" ,
438
+ " imageop" ,
439
+ " imp" ,
440
+ " itertools" ,
441
+ " marshal" ,
442
+ " math" ,
443
+ " matplotlib" ,
444
+ " mmap" ,
445
+ " mpmath" ,
446
+ " msvcrt" ,
447
+ " networkx" ,
448
+ " nose" ,
449
+ " nt" ,
450
+ " numpy" ,
451
+ " operator" ,
452
+ " os" ,
453
+ " os.path" ,
454
+ " pandas" ,
455
+ " parser" ,
456
+ " rgbimg" ,
457
+ " scipy" ,
458
+ " signal" ,
459
+ " skimage" ,
460
+ " sklearn" ,
461
+ " statsmodels" ,
462
+ " strop" ,
463
+ " sympy" ,
464
+ " sys" ,
465
+ " thread" ,
466
+ " time" ,
467
+ " wx" ,
468
+ " xxsubtype" ,
469
+ " zipimport" ,
470
+ " zlib"
471
+ ],
472
+ "items" : {
473
+ "type" : " string"
474
+ },
475
+ "description" : " Builtin and c-extension modules that are allowed to be imported and inspected by rope."
476
+ }
477
+ }
348
478
}
349
479
},
350
480
"consumedServices" : {
Original file line number Diff line number Diff line change 1
1
const path = require ( "path" ) ;
2
- const { detectVirtualEnv } = require ( "../lib/utils" ) ;
2
+ const { detectVirtualEnv, sanitizeConfig } = require ( "../lib/utils" ) ;
3
3
4
4
const venvFixturesDir = path . join ( __dirname , "fixtures" , "venv" ) ;
5
5
@@ -50,3 +50,24 @@ describe("detectVirtualEnv", () => {
50
50
} ) ;
51
51
} ) ;
52
52
} ) ;
53
+
54
+ describe ( "sanitizeConfig" , ( ) => {
55
+ it ( "converts 'null' to null" , ( ) => {
56
+ const config = {
57
+ ropeFolder : "null" ,
58
+ extensionModules : [ "numpy" , "pandas" ]
59
+ } ;
60
+ expect ( sanitizeConfig ( config ) ) . toEqual ( {
61
+ ropeFolder : null ,
62
+ extensionModules : [ "numpy" , "pandas" ]
63
+ } ) ;
64
+ } ) ;
65
+
66
+ it ( "doesn't change object" , ( ) => {
67
+ const config = {
68
+ ropeFolder : ".ropeproject" ,
69
+ extensionModules : [ "numpy" , "pandas" ]
70
+ } ;
71
+ expect ( sanitizeConfig ( config ) ) . toEqual ( config ) ;
72
+ } ) ;
73
+ } ) ;
You can’t perform that action at this time.
0 commit comments