GeezerVison is showing github.com — Restore the JSON schema, add human-readable configuration (#51) · deepnote/python-lsp-server@87b76d7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/static.yml +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,11 +30,17 @@ jobs: | 30 | 30 | # errors first | 31 | 31 | python-version: '3.6' | 32 | 32 | architecture: 'x64' | 33 | | - - run: python -m pip install --upgrade pip setuptools | | 33 | + - run: python -m pip install --upgrade pip setuptools jsonschema | 34 | 34 | - run: pip install -e .[pylint,pycodestyle,pyflakes] | 35 | 35 | - name: Pylint checks | 36 | 36 | run: pylint pylsp test | 37 | 37 | - name: Code style checks | 38 | 38 | run: pycodestyle pylsp test | 39 | 39 | - name: Pyflakes checks | 40 | 40 | run: pyflakes pylsp test | | 41 | + - name: Validate JSON schema | | 42 | + run: jsonschema pylsp/config/schema.json | | 43 | + - name: Ensure JSON schema and Markdown docs are in sync | | 44 | + run: | | | 45 | + python scripts/jsonschema2md.py pylsp/config/schema.json EXPECTED_CONFIGURATION.md | | 46 | + diff EXPECTED_CONFIGURATION.md CONFIGURATION.md |
Collapse file Copy file name to clipboard +50Lines changed: 50 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# Python Language Server Configuration | | 2 | +This server can be configured using `workspace/didChangeConfiguration` method. Each configuration option is described below: | | 3 | + | | 4 | +| **Configuration Key** | **Type** | **Description** | **Default** | | 5 | +|----|----|----|----| | | 6 | +| `pylsp.configurationSources` | `array` of unique `string` items | List of configuration sources to use. | `["pycodestyle"]` | | | 7 | +| `pylsp.plugins.jedi.extra_paths` | `array` | Define extra paths for jedi.Script. | `[]` | | | 8 | +| `pylsp.plugins.jedi.env_vars` | `object` | Define environment variables for jedi.Script and Jedi.names. | `null` | | | 9 | +| `pylsp.plugins.jedi.environment` | `string` | Define environment for jedi.Script and Jedi.names. | `null` | | | 10 | +| `pylsp.plugins.jedi_completion.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 11 | +| `pylsp.plugins.jedi_completion.include_params` | `boolean` | Auto-completes methods and classes with tabstops for each parameter. | `true` | | | 12 | +| `pylsp.plugins.jedi_completion.include_class_objects` | `boolean` | Adds class objects as a separate completion item. | `true` | | | 13 | +| `pylsp.plugins.jedi_completion.fuzzy` | `boolean` | Enable fuzzy when requesting autocomplete. | `false` | | | 14 | +| `pylsp.plugins.jedi_definition.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 15 | +| `pylsp.plugins.jedi_definition.follow_imports` | `boolean` | The goto call will follow imports. | `true` | | | 16 | +| `pylsp.plugins.jedi_definition.follow_builtin_imports` | `boolean` | If follow_imports is True will decide if it follow builtin imports. | `true` | | | 17 | +| `pylsp.plugins.jedi_hover.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 18 | +| `pylsp.plugins.jedi_references.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 19 | +| `pylsp.plugins.jedi_signature_help.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 20 | +| `pylsp.plugins.jedi_symbols.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 21 | +| `pylsp.plugins.jedi_symbols.all_scopes` | `boolean` | If True lists the names of all scopes instead of only the module namespace. | `true` | | | 22 | +| `pylsp.plugins.mccabe.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 23 | +| `pylsp.plugins.mccabe.threshold` | `number` | The minimum threshold that triggers warnings about cyclomatic complexity. | `15` | | | 24 | +| `pylsp.plugins.preload.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 25 | +| `pylsp.plugins.preload.modules` | `array` of unique `string` items | List of modules to import on startup | `null` | | | 26 | +| `pylsp.plugins.pycodestyle.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 27 | +| `pylsp.plugins.pycodestyle.exclude` | `array` of unique `string` items | Exclude files or directories which match these patterns. | `null` | | | 28 | +| `pylsp.plugins.pycodestyle.filename` | `array` of unique `string` items | When parsing directories, only check filenames matching these patterns. | `null` | | | 29 | +| `pylsp.plugins.pycodestyle.select` | `array` of unique `string` items | Select errors and warnings | `null` | | | 30 | +| `pylsp.plugins.pycodestyle.ignore` | `array` of unique `string` items | Ignore errors and warnings | `null` | | | 31 | +| `pylsp.plugins.pycodestyle.hangClosing` | `boolean` | Hang closing bracket instead of matching indentation of opening bracket's line. | `null` | | | 32 | +| `pylsp.plugins.pycodestyle.maxLineLength` | `number` | Set maximum allowed line length. | `null` | | | 33 | +| `pylsp.plugins.pydocstyle.enabled` | `boolean` | Enable or disable the plugin. | `false` | | | 34 | +| `pylsp.plugins.pydocstyle.convention` | `string` | Choose the basic list of checked errors by specifying an existing convention. | `null` | | | 35 | +| `pylsp.plugins.pydocstyle.addIgnore` | `array` of unique `string` items | Ignore errors and warnings in addition to the specified convention. | `null` | | | 36 | +| `pylsp.plugins.pydocstyle.addSelect` | `array` of unique `string` items | Select errors and warnings in addition to the specified convention. | `null` | | | 37 | +| `pylsp.plugins.pydocstyle.ignore` | `array` of unique `string` items | Ignore errors and warnings | `null` | | | 38 | +| `pylsp.plugins.pydocstyle.select` | `array` of unique `string` items | Select errors and warnings | `null` | | | 39 | +| `pylsp.plugins.pydocstyle.match` | `string` | Check only files that exactly match the given regular expression; default is to match files that don't start with 'test_' but end with '.py'. | `"(?!test_).*\\.py"` | | | 40 | +| `pylsp.plugins.pydocstyle.matchDir` | `string` | Search only dirs that exactly match the given regular expression; default is to match dirs which do not begin with a dot. | `"[^\\.].*"` | | | 41 | +| `pylsp.plugins.pyflakes.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 42 | +| `pylsp.plugins.pylint.enabled` | `boolean` | Enable or disable the plugin. | `false` | | | 43 | +| `pylsp.plugins.pylint.args` | `array` of non-unique `string` items | Arguments to pass to pylint. | `null` | | | 44 | +| `pylsp.plugins.pylint.executable` | `string` | Executable to run pylint with. Enabling this will run pylint on unsaved files via stdin. Can slow down workflow. Only works with python3. | `null` | | | 45 | +| `pylsp.plugins.rope_completion.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 46 | +| `pylsp.plugins.yapf.enabled` | `boolean` | Enable or disable the plugin. | `true` | | | 47 | +| `pylsp.rope.extensionModules` | `string` | Builtin and c-extension modules that are allowed to be imported and inspected by rope. | `null` | | | 48 | +| `pylsp.rope.ropeFolder` | `array` of unique `string` items | The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all. | `null` | | | 49 | + | | 50 | +This documentation was generated from `pylsp/config/schema.json`. Please do not edit this file directly. |
Collapse file Copy file name to clipboardExpand all lines: README.md +9-1Lines changed: 9 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -60,11 +60,13 @@ Configuration is loaded from zero or more configuration sources. Currently impl | 60 | 60 |
| 61 | 61 | The default configuration source is pycodestyle. Change the `pylsp.configurationSources` setting to `['flake8']` in order to respect flake8 configuration instead. | 62 | 62 |
| 63 | | -Overall configuration is computed first from user configuration (in home directory), overridden by configuration passed in by the language client, and then overriden by configuration discovered in the workspace. | | 63 | +Overall configuration is computed first from user configuration (in home directory), overridden by configuration passed in by the language client, and then overridden by configuration discovered in the workspace. | 64 | 64 |
| 65 | 65 | To enable pydocstyle for linting docstrings add the following setting in your LSP configuration: | 66 | 66 | `"pylsp.plugins.pydocstyle.enabled": true` | 67 | 67 |
| | 68 | +All configuration options are described in [`CONFIGURATION.md`](https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md). | | 69 | + | 68 | 70 | ## LSP Server Features | 69 | 71 |
| 70 | 72 | * Auto Completion | @@ -86,6 +88,12 @@ To run the test suite: | 86 | 88 | pip install .[test] && pytest | 87 | 89 | ``` | 88 | 90 |
| | 91 | +After adding configuration options to `schema.json`, refresh the `CONFIGURATION.md` file with | | 92 | + | | 93 | +``` | | 94 | +python scripts/jsonschema2md.py pylsp/config/schema.json CONFIGURATION.md | | 95 | +``` | | 96 | + | 89 | 97 | ## License | 90 | 98 |
| 91 | 99 | This project is made available under the MIT License. |
Collapse file Copy file name to clipboard +276Lines changed: 276 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "$schema": "http://json-schema.org/draft-07/schema#", | | 3 | + "title": "Python Language Server Configuration", | | 4 | + "description": "This server can be configured using `workspace/didChangeConfiguration` method. Each configuration option is described below:", | | 5 | + "type": "object", | | 6 | + "properties": { | | 7 | + "pylsp.configurationSources": { | | 8 | + "type": "array", | | 9 | + "default": ["pycodestyle"], | | 10 | + "description": "List of configuration sources to use.", | | 11 | + "items": { | | 12 | + "type": "string", | | 13 | + "enum": ["pycodestyle", "pyflakes"] | | 14 | + }, | | 15 | + "uniqueItems": true | | 16 | + }, | | 17 | + "pylsp.plugins.jedi.extra_paths": { | | 18 | + "type": "array", | | 19 | + "default": [], | | 20 | + "description": "Define extra paths for jedi.Script." | | 21 | + }, | | 22 | + "pylsp.plugins.jedi.env_vars": { | | 23 | + "type": "object", | | 24 | + "default": null, | | 25 | + "description": "Define environment variables for jedi.Script and Jedi.names." | | 26 | + }, | | 27 | + "pylsp.plugins.jedi.environment": { | | 28 | + "type": "string", | | 29 | + "default": null, | | 30 | + "description": "Define environment for jedi.Script and Jedi.names." | | 31 | + }, | | 32 | + "pylsp.plugins.jedi_completion.enabled": { | | 33 | + "type": "boolean", | | 34 | + "default": true, | | 35 | + "description": "Enable or disable the plugin." | | 36 | + }, | | 37 | + "pylsp.plugins.jedi_completion.include_params": { | | 38 | + "type": "boolean", | | 39 | + "default": true, | | 40 | + "description": "Auto-completes methods and classes with tabstops for each parameter." | | 41 | + }, | | 42 | + "pylsp.plugins.jedi_completion.include_class_objects": { | | 43 | + "type": "boolean", | | 44 | + "default": true, | | 45 | + "description": "Adds class objects as a separate completion item." | | 46 | + }, | | 47 | + "pylsp.plugins.jedi_completion.fuzzy": { | | 48 | + "type": "boolean", | | 49 | + "default": false, | | 50 | + "description": "Enable fuzzy when requesting autocomplete." | | 51 | + }, | | 52 | + "pylsp.plugins.jedi_definition.enabled": { | | 53 | + "type": "boolean", | | 54 | + "default": true, | | 55 | + "description": "Enable or disable the plugin." | | 56 | + }, | | 57 | + "pylsp.plugins.jedi_definition.follow_imports": { | | 58 | + "type": "boolean", | | 59 | + "default": true, | | 60 | + "description": "The goto call will follow imports." | | 61 | + }, | | 62 | + "pylsp.plugins.jedi_definition.follow_builtin_imports": { | | 63 | + "type": "boolean", | | 64 | + "default": true, | | 65 | + "description": "If follow_imports is True will decide if it follow builtin imports." | | 66 | + }, | | 67 | + "pylsp.plugins.jedi_hover.enabled": { | | 68 | + "type": "boolean", | | 69 | + "default": true, | | 70 | + "description": "Enable or disable the plugin." | | 71 | + }, | | 72 | + "pylsp.plugins.jedi_references.enabled": { | | 73 | + "type": "boolean", | | 74 | + "default": true, | | 75 | + "description": "Enable or disable the plugin." | | 76 | + }, | | 77 | + "pylsp.plugins.jedi_signature_help.enabled": { | | 78 | + "type": "boolean", | | 79 | + "default": true, | | 80 | + "description": "Enable or disable the plugin." | | 81 | + }, | | 82 | + "pylsp.plugins.jedi_symbols.enabled": { | | 83 | + "type": "boolean", | | 84 | + "default": true, | | 85 | + "description": "Enable or disable the plugin." | | 86 | + }, | | 87 | + "pylsp.plugins.jedi_symbols.all_scopes": { | | 88 | + "type": "boolean", | | 89 | + "default": true, | | 90 | + "description": "If True lists the names of all scopes instead of only the module namespace." | | 91 | + }, | | 92 | + "pylsp.plugins.mccabe.enabled": { | | 93 | + "type": "boolean", | | 94 | + "default": true, | | 95 | + "description": "Enable or disable the plugin." | | 96 | + }, | | 97 | + "pylsp.plugins.mccabe.threshold": { | | 98 | + "type": "number", | | 99 | + "default": 15, | | 100 | + "description": "The minimum threshold that triggers warnings about cyclomatic complexity." | | 101 | + }, | | 102 | + "pylsp.plugins.preload.enabled": { | | 103 | + "type": "boolean", | | 104 | + "default": true, | | 105 | + "description": "Enable or disable the plugin." | | 106 | + }, | | 107 | + "pylsp.plugins.preload.modules": { | | 108 | + "type": "array", | | 109 | + "default": null, | | 110 | + "items": { | | 111 | + "type": "string" | | 112 | + }, | | 113 | + "uniqueItems": true, | | 114 | + "description": "List of modules to import on startup" | | 115 | + }, | | 116 | + "pylsp.plugins.pycodestyle.enabled": { | | 117 | + "type": "boolean", | | 118 | + "default": true, | | 119 | + "description": "Enable or disable the plugin." | | 120 | + }, | | 121 | + "pylsp.plugins.pycodestyle.exclude": { | | 122 | + "type": "array", | | 123 | + "default": null, | | 124 | + "items": { | | 125 | + "type": "string" | | 126 | + }, | | 127 | + "uniqueItems": true, | | 128 | + "description": "Exclude files or directories which match these patterns." | | 129 | + }, | | 130 | + "pylsp.plugins.pycodestyle.filename": { | | 131 | + "type": "array", | | 132 | + "default": null, | | 133 | + "items": { | | 134 | + "type": "string" | | 135 | + }, | | 136 | + "uniqueItems": true, | | 137 | + "description": "When parsing directories, only check filenames matching these patterns." | | 138 | + }, | | 139 | + "pylsp.plugins.pycodestyle.select": { | | 140 | + "type": "array", | | 141 | + "default": null, | | 142 | + "items": { | | 143 | + "type": "string" | | 144 | + }, | | 145 | + "uniqueItems": true, | | 146 | + "description": "Select errors and warnings" | | 147 | + }, | | 148 | + "pylsp.plugins.pycodestyle.ignore": { | | 149 | + "type": "array", | | 150 | + "default": null, | | 151 | + "items": { | | 152 | + "type": "string" | | 153 | + }, | | 154 | + "uniqueItems": true, | | 155 | + "description": "Ignore errors and warnings" | | 156 | + }, | | 157 | + "pylsp.plugins.pycodestyle.hangClosing": { | | 158 | + "type": "boolean", | | 159 | + "default": null, | | 160 | + "description": "Hang closing bracket instead of matching indentation of opening bracket's line." | | 161 | + }, | | 162 | + "pylsp.plugins.pycodestyle.maxLineLength": { | | 163 | + "type": "number", | | 164 | + "default": null, | | 165 | + "description": "Set maximum allowed line length." | | 166 | + }, | | 167 | + "pylsp.plugins.pydocstyle.enabled": { | | 168 | + "type": "boolean", | | 169 | + "default": false, | | 170 | + "description": "Enable or disable the plugin." | | 171 | + }, | | 172 | + "pylsp.plugins.pydocstyle.convention": { | | 173 | + "type": "string", | | 174 | + "default": null, | | 175 | + "enum": [ | | 176 | + "pep257", | | 177 | + "numpy" | | 178 | + ], | | 179 | + "description": "Choose the basic list of checked errors by specifying an existing convention." | | 180 | + }, | | 181 | + "pylsp.plugins.pydocstyle.addIgnore": { | | 182 | + "type": "array", | | 183 | + "default": null, | | 184 | + "items": { | | 185 | + "type": "string" | | 186 | + }, | | 187 | + "uniqueItems": true, | | 188 | + "description": "Ignore errors and warnings in addition to the specified convention." | | 189 | + }, | | 190 | + "pylsp.plugins.pydocstyle.addSelect": { | | 191 | + "type": "array", | | 192 | + "default": null, | | 193 | + "items": { | | 194 | + "type": "string" | | 195 | + }, | | 196 | + "uniqueItems": true, | | 197 | + "description": "Select errors and warnings in addition to the specified convention." | | 198 | + }, | | 199 | + "pylsp.plugins.pydocstyle.ignore": { | | 200 | + "type": "array", | | 201 | + "default": null, | | 202 | + "items": { | | 203 | + "type": "string" | | 204 | + }, | | 205 | + "uniqueItems": true, | | 206 | + "description": "Ignore errors and warnings" | | 207 | + }, | | 208 | + "pylsp.plugins.pydocstyle.select": { | | 209 | + "type": "array", | | 210 | + "default": null, | | 211 | + "items": { | | 212 | + "type": "string" | | 213 | + }, | | 214 | + "uniqueItems": true, | | 215 | + "description": "Select errors and warnings" | | 216 | + }, | | 217 | + "pylsp.plugins.pydocstyle.match": { | | 218 | + "type": "string", | | 219 | + "default": "(?!test_).*\\.py", | | 220 | + "description": "Check only files that exactly match the given regular expression; default is to match files that don't start with 'test_' but end with '.py'." | | 221 | + }, | | 222 | + "pylsp.plugins.pydocstyle.matchDir": { | | 223 | + "type": "string", | | 224 | + "default": "[^\\.].*", | | 225 | + "description": "Search only dirs that exactly match the given regular expression; default is to match dirs which do not begin with a dot." | | 226 | + }, | | 227 | + "pylsp.plugins.pyflakes.enabled": { | | 228 | + "type": "boolean", | | 229 | + "default": true, | | 230 | + "description": "Enable or disable the plugin." | | 231 | + }, | | 232 | + "pylsp.plugins.pylint.enabled": { | | 233 | + "type": "boolean", | | 234 | + "default": false, | | 235 | + "description": "Enable or disable the plugin." | | 236 | + }, | | 237 | + "pylsp.plugins.pylint.args": { | | 238 | + "type": "array", | | 239 | + "default": null, | | 240 | + "items": { | | 241 | + "type": "string" | | 242 | + }, | | 243 | + "uniqueItems": false, | | 244 | + "description": "Arguments to pass to pylint." | | 245 | + }, | | 246 | + "pylsp.plugins.pylint.executable": { | | 247 | + "type": "string", | | 248 | + "default": null, | | 249 | + "description": "Executable to run pylint with. Enabling this will run pylint on unsaved files via stdin. Can slow down workflow. Only works with python3." | | 250 | + }, | | 251 | + "pylsp.plugins.rope_completion.enabled": { | | 252 | + "type": "boolean", | | 253 | + "default": true, | | 254 | + "description": "Enable or disable the plugin." | | 255 | + }, | | 256 | + "pylsp.plugins.yapf.enabled": { | | 257 | + "type": "boolean", | | 258 | + "default": true, | | 259 | + "description": "Enable or disable the plugin." | | 260 | + }, | | 261 | + "pylsp.rope.extensionModules": { | | 262 | + "type": "string", | | 263 | + "default": null, | | 264 | + "description": "Builtin and c-extension modules that are allowed to be imported and inspected by rope." | | 265 | + }, | | 266 | + "pylsp.rope.ropeFolder": { | | 267 | + "type": "array", | | 268 | + "default": null, | | 269 | + "items": { | | 270 | + "type": "string" | | 271 | + }, | | 272 | + "uniqueItems": true, | | 273 | + "description": "The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all." | | 274 | + } | | 275 | + } | | 276 | +} |
Collapse file Copy file name to clipboardExpand all lines: pylsp/plugins/jedi_completion.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -114,7 +114,7 @@ def use_snippets(document, position): | 114 | 114 | break | 115 | 115 | if '(' in act_lines[-1].strip(): | 116 | 116 | last_character = ')' | 117 | | - code = '\n'.join(act_lines).split(';')[-1].strip() + last_character | | 117 | + code = '\n'.join(act_lines).rsplit(';', maxsplit=1)[-1].strip() + last_character | 118 | 118 | tokens = parso.parse(code) | 119 | 119 | expr_type = tokens.children[0].type | 120 | 120 | return (expr_type not in _IMPORTS and | |
|