Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const cp = require("child_process");
const { shell } = require("electron");
const { AutoLanguageClient } = require("atom-languageclient");
const { detectVirtualEnv } = require("./utils");
const { detectVirtualEnv, sanitizeConfig } = require("./utils");

// Ref: https://github.com/nteract/hydrogen/blob/master/lib/autocomplete-provider.js#L33
// adapted from http://stackoverflow.com/q/5474008
Expand Down Expand Up @@ -34,7 +34,7 @@ class PythonLanguageClient extends AutoLanguageClient {
return {
pyls: {
configurationSources: configuration.pylsConfigurationSources,
rope: { ropeFolder: configuration.ropeFolder !== "null" ? configuration.ropeFolder : null },
rope: sanitizeConfig(configuration.rope),
plugins: configuration.pylsPlugins
}
};
Expand Down
10 changes: 10 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@ async function detectVirtualEnv(path) {
}
}

function sanitizeConfig(config) {
Object.entries(config).forEach(([key, value]) => {
if (value === "null") {
config[key] = null;
}
});
return config;
}

exports.detectVirtualEnv = detectVirtualEnv;
exports.sanitizeConfig = sanitizeConfig;
142 changes: 136 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,10 @@
]
}
},
"ropeFolder": {
"order": 3,
"type": "string",
"default": ".ropeproject",
"description": "The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all."
},
"pylsPlugins": {
"title": "Python Language Server Plugins",
"type": "object",
"order": 3,
"properties": {
"jedi_completion": {
"title": "Jedi Completion",
Expand Down Expand Up @@ -162,6 +157,74 @@
}
}
},
"preload": {
"title": "Preload",
"type": "object",
"properties": {
"enabled": {
"title": "Enabled",
"type": "boolean",
"default": true,
"description": "Enable or disable preload."
},
"modules": {
"title": "Modules",
"type": "array",
"default": [
"OpenGL",
"PIL",
"array",
"audioop",
"binascii",
"cPickle",
"cStringIO",
"cmath",
"collections",
"datetime",
"errno",
"exceptions",
"gc",
"imageop",
"imp",
"itertools",
"marshal",
"math",
"matplotlib",
"mmap",
"mpmath",
"msvcrt",
"networkx",
"nose",
"nt",
"numpy",
"operator",
"os",
"os.path",
"pandas",
"parser",
"rgbimg",
"scipy",
"signal",
"skimage",
"sklearn",
"statsmodels",
"strop",
"sympy",
"sys",
"thread",
"time",
"wx",
"xxsubtype",
"zipimport",
"zlib"
],
"items": {
"type": "string"
},
"description": "List of modules to import on startup"
}
}
},
"pycodestyle": {
"title": "PyCodeStyle",
"type": "object",
Expand Down Expand Up @@ -345,6 +408,73 @@
}
}
}
},
"rope": {
"type": "object",
"properties": {
"ropeFolder": {
"title": "Rope Folder",
"type": "string",
"default": ".ropeproject",
"description": "The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all."
},
"extensionModules": {
"title": "Extension Modules",
"type": "array",
"default": [
"OpenGL",
"PIL",
"array",
"audioop",
"binascii",
"cPickle",
"cStringIO",
"cmath",
"collections",
"datetime",
"errno",
"exceptions",
"gc",
"imageop",
"imp",
"itertools",
"marshal",
"math",
"matplotlib",
"mmap",
"mpmath",
"msvcrt",
"networkx",
"nose",
"nt",
"numpy",
"operator",
"os",
"os.path",
"pandas",
"parser",
"rgbimg",
"scipy",
"signal",
"skimage",
"sklearn",
"statsmodels",
"strop",
"sympy",
"sys",
"thread",
"time",
"wx",
"xxsubtype",
"zipimport",
"zlib"
],
"items": {
"type": "string"
},
"description": "Builtin and c-extension modules that are allowed to be imported and inspected by rope."
}
}
}
},
"consumedServices": {
Expand Down
23 changes: 22 additions & 1 deletion spec/utils-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require("path");
const { detectVirtualEnv } = require("../lib/utils");
const { detectVirtualEnv, sanitizeConfig } = require("../lib/utils");

const venvFixturesDir = path.join(__dirname, "fixtures", "venv");

Expand Down Expand Up @@ -50,3 +50,24 @@ describe("detectVirtualEnv", () => {
});
});
});

describe("sanitizeConfig", () => {
it("converts 'null' to null", () => {
const config = {
ropeFolder: "null",
extensionModules: ["numpy", "pandas"]
};
expect(sanitizeConfig(config)).toEqual({
ropeFolder: null,
extensionModules: ["numpy", "pandas"]
});
});

it("doesn't change object", () => {
const config = {
ropeFolder: ".ropeproject",
extensionModules: ["numpy", "pandas"]
};
expect(sanitizeConfig(config)).toEqual(config);
});
});