deepnote-python-lsp-server 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. deepnote_python_lsp_server-0.0.0/.pylintrc +31 -0
  2. deepnote_python_lsp_server-0.0.0/LICENSE +22 -0
  3. deepnote_python_lsp_server-0.0.0/MANIFEST.in +7 -0
  4. deepnote_python_lsp_server-0.0.0/PKG-INFO +263 -0
  5. deepnote_python_lsp_server-0.0.0/README.md +203 -0
  6. deepnote_python_lsp_server-0.0.0/deepnote_python_lsp_server.egg-info/PKG-INFO +263 -0
  7. deepnote_python_lsp_server-0.0.0/deepnote_python_lsp_server.egg-info/SOURCES.txt +79 -0
  8. deepnote_python_lsp_server-0.0.0/deepnote_python_lsp_server.egg-info/dependency_links.txt +1 -0
  9. deepnote_python_lsp_server-0.0.0/deepnote_python_lsp_server.egg-info/entry_points.txt +24 -0
  10. deepnote_python_lsp_server-0.0.0/deepnote_python_lsp_server.egg-info/requires.txt +62 -0
  11. deepnote_python_lsp_server-0.0.0/deepnote_python_lsp_server.egg-info/top_level.txt +1 -0
  12. deepnote_python_lsp_server-0.0.0/pylsp/__init__.py +33 -0
  13. deepnote_python_lsp_server-0.0.0/pylsp/__main__.py +132 -0
  14. deepnote_python_lsp_server-0.0.0/pylsp/_utils.py +325 -0
  15. deepnote_python_lsp_server-0.0.0/pylsp/config/__init__.py +2 -0
  16. deepnote_python_lsp_server-0.0.0/pylsp/config/config.py +202 -0
  17. deepnote_python_lsp_server-0.0.0/pylsp/config/flake8_conf.py +64 -0
  18. deepnote_python_lsp_server-0.0.0/pylsp/config/pycodestyle_conf.py +34 -0
  19. deepnote_python_lsp_server-0.0.0/pylsp/config/source.py +88 -0
  20. deepnote_python_lsp_server-0.0.0/pylsp/hookspecs.py +140 -0
  21. deepnote_python_lsp_server-0.0.0/pylsp/lsp.py +115 -0
  22. deepnote_python_lsp_server-0.0.0/pylsp/plugins/__init__.py +2 -0
  23. deepnote_python_lsp_server-0.0.0/pylsp/plugins/_resolvers.py +132 -0
  24. deepnote_python_lsp_server-0.0.0/pylsp/plugins/_rope_task_handle.py +106 -0
  25. deepnote_python_lsp_server-0.0.0/pylsp/plugins/autopep8_format.py +95 -0
  26. deepnote_python_lsp_server-0.0.0/pylsp/plugins/definition.py +84 -0
  27. deepnote_python_lsp_server-0.0.0/pylsp/plugins/flake8_lint.py +243 -0
  28. deepnote_python_lsp_server-0.0.0/pylsp/plugins/folding.py +210 -0
  29. deepnote_python_lsp_server-0.0.0/pylsp/plugins/highlight.py +36 -0
  30. deepnote_python_lsp_server-0.0.0/pylsp/plugins/hover.py +57 -0
  31. deepnote_python_lsp_server-0.0.0/pylsp/plugins/jedi_completion.py +318 -0
  32. deepnote_python_lsp_server-0.0.0/pylsp/plugins/jedi_rename.py +56 -0
  33. deepnote_python_lsp_server-0.0.0/pylsp/plugins/mccabe_lint.py +56 -0
  34. deepnote_python_lsp_server-0.0.0/pylsp/plugins/preload_imports.py +38 -0
  35. deepnote_python_lsp_server-0.0.0/pylsp/plugins/pycodestyle_lint.py +113 -0
  36. deepnote_python_lsp_server-0.0.0/pylsp/plugins/pydocstyle_lint.py +127 -0
  37. deepnote_python_lsp_server-0.0.0/pylsp/plugins/pyflakes_lint.py +97 -0
  38. deepnote_python_lsp_server-0.0.0/pylsp/plugins/pylint_lint.py +367 -0
  39. deepnote_python_lsp_server-0.0.0/pylsp/plugins/references.py +33 -0
  40. deepnote_python_lsp_server-0.0.0/pylsp/plugins/rope_autoimport.py +407 -0
  41. deepnote_python_lsp_server-0.0.0/pylsp/plugins/rope_completion.py +161 -0
  42. deepnote_python_lsp_server-0.0.0/pylsp/plugins/signature.py +81 -0
  43. deepnote_python_lsp_server-0.0.0/pylsp/plugins/symbols.py +214 -0
  44. deepnote_python_lsp_server-0.0.0/pylsp/plugins/yapf_format.py +199 -0
  45. deepnote_python_lsp_server-0.0.0/pylsp/python_lsp.py +921 -0
  46. deepnote_python_lsp_server-0.0.0/pylsp/text_edit.py +97 -0
  47. deepnote_python_lsp_server-0.0.0/pylsp/uris.py +139 -0
  48. deepnote_python_lsp_server-0.0.0/pylsp/workspace.py +730 -0
  49. deepnote_python_lsp_server-0.0.0/pyproject.toml +186 -0
  50. deepnote_python_lsp_server-0.0.0/setup.cfg +4 -0
  51. deepnote_python_lsp_server-0.0.0/setup.py +11 -0
  52. deepnote_python_lsp_server-0.0.0/test/__init__.py +9 -0
  53. deepnote_python_lsp_server-0.0.0/test/conftest.py +13 -0
  54. deepnote_python_lsp_server-0.0.0/test/fixtures.py +179 -0
  55. deepnote_python_lsp_server-0.0.0/test/plugins/__init__.py +0 -0
  56. deepnote_python_lsp_server-0.0.0/test/plugins/test_autoimport.py +348 -0
  57. deepnote_python_lsp_server-0.0.0/test/plugins/test_autopep8_format.py +86 -0
  58. deepnote_python_lsp_server-0.0.0/test/plugins/test_completion.py +598 -0
  59. deepnote_python_lsp_server-0.0.0/test/plugins/test_definitions.py +175 -0
  60. deepnote_python_lsp_server-0.0.0/test/plugins/test_flake8_lint.py +258 -0
  61. deepnote_python_lsp_server-0.0.0/test/plugins/test_folding.py +181 -0
  62. deepnote_python_lsp_server-0.0.0/test/plugins/test_highlight.py +63 -0
  63. deepnote_python_lsp_server-0.0.0/test/plugins/test_hover.py +111 -0
  64. deepnote_python_lsp_server-0.0.0/test/plugins/test_jedi_rename.py +105 -0
  65. deepnote_python_lsp_server-0.0.0/test/plugins/test_mccabe_lint.py +39 -0
  66. deepnote_python_lsp_server-0.0.0/test/plugins/test_pycodestyle_lint.py +136 -0
  67. deepnote_python_lsp_server-0.0.0/test/plugins/test_pydocstyle_lint.py +59 -0
  68. deepnote_python_lsp_server-0.0.0/test/plugins/test_pyflakes_lint.py +69 -0
  69. deepnote_python_lsp_server-0.0.0/test/plugins/test_pylint_lint.py +139 -0
  70. deepnote_python_lsp_server-0.0.0/test/plugins/test_references.py +82 -0
  71. deepnote_python_lsp_server-0.0.0/test/plugins/test_signature.py +106 -0
  72. deepnote_python_lsp_server-0.0.0/test/plugins/test_symbols.py +103 -0
  73. deepnote_python_lsp_server-0.0.0/test/plugins/test_yapf_format.py +115 -0
  74. deepnote_python_lsp_server-0.0.0/test/test_configuration.py +53 -0
  75. deepnote_python_lsp_server-0.0.0/test/test_document.py +105 -0
  76. deepnote_python_lsp_server-0.0.0/test/test_language_server.py +86 -0
  77. deepnote_python_lsp_server-0.0.0/test/test_notebook_document.py +532 -0
  78. deepnote_python_lsp_server-0.0.0/test/test_text_edit.py +303 -0
  79. deepnote_python_lsp_server-0.0.0/test/test_uris.py +72 -0
  80. deepnote_python_lsp_server-0.0.0/test/test_utils.py +266 -0
  81. deepnote_python_lsp_server-0.0.0/test/test_workspace.py +432 -0
@@ -0,0 +1,31 @@
1
+ [FORMAT]
2
+
3
+ max-line-length = 120
4
+
5
+ [MESSAGES CONTROL]
6
+
7
+ enable =
8
+ useless-suppression
9
+
10
+ disable =
11
+ duplicate-code,
12
+ invalid-name,
13
+ fixme,
14
+ missing-docstring,
15
+ protected-access,
16
+ too-few-public-methods,
17
+ too-many-arguments,
18
+ too-many-instance-attributes,
19
+ import-error,
20
+ consider-using-f-string,
21
+ logging-fstring-interpolation
22
+
23
+ [REPORTS]
24
+
25
+ reports = no
26
+
27
+ [TYPECHECK]
28
+
29
+ generated-members =
30
+ pylsp_*
31
+ cache_clear
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2017-2020 Palantir Technologies, Inc.
4
+ Copyright 2021 Python Language Server Contributors.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include README.md
2
+ include versioneer.py
3
+ include pylsp/_version.py
4
+ include LICENSE
5
+ include ruff.toml
6
+ include .pylintrc
7
+ recursive-include test *.py
@@ -0,0 +1,263 @@
1
+ Metadata-Version: 2.4
2
+ Name: deepnote-python-lsp-server
3
+ Version: 0.0.0
4
+ Summary: Python Language Server for the Language Server Protocol
5
+ Author: Python Language Server Contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/deepnote/python-lsp-server
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: docstring-to-markdown
12
+ Requires-Dist: importlib_metadata>=4.8.3; python_version < "3.10"
13
+ Requires-Dist: jedi<0.20.0,>=0.17.2
14
+ Requires-Dist: pluggy>=1.0.0
15
+ Requires-Dist: python-lsp-jsonrpc<2.0.0,>=1.1.0
16
+ Requires-Dist: ujson>=3.0.0
17
+ Provides-Extra: all
18
+ Requires-Dist: autopep8<2.1.0,>=2.0.4; extra == "all"
19
+ Requires-Dist: flake8<8,>=7.1; extra == "all"
20
+ Requires-Dist: mccabe<0.8.0,>=0.7.0; extra == "all"
21
+ Requires-Dist: pycodestyle<2.13.0,>=2.12.0; extra == "all"
22
+ Requires-Dist: pydocstyle<6.4.0,>=6.3.0; extra == "all"
23
+ Requires-Dist: pyflakes<3.3.0,>=3.2.0; extra == "all"
24
+ Requires-Dist: pylint<4,>=3.1; extra == "all"
25
+ Requires-Dist: rope>=1.11.0; extra == "all"
26
+ Requires-Dist: yapf>=0.33.0; extra == "all"
27
+ Requires-Dist: whatthepatch<2.0.0,>=1.0.2; extra == "all"
28
+ Provides-Extra: autopep8
29
+ Requires-Dist: autopep8<2.1.0,>=2.0.4; extra == "autopep8"
30
+ Provides-Extra: flake8
31
+ Requires-Dist: flake8<8,>=7.1; extra == "flake8"
32
+ Provides-Extra: mccabe
33
+ Requires-Dist: mccabe<0.8.0,>=0.7.0; extra == "mccabe"
34
+ Provides-Extra: pycodestyle
35
+ Requires-Dist: pycodestyle<2.13.0,>=2.12.0; extra == "pycodestyle"
36
+ Provides-Extra: pydocstyle
37
+ Requires-Dist: pydocstyle<6.4.0,>=6.3.0; extra == "pydocstyle"
38
+ Provides-Extra: pyflakes
39
+ Requires-Dist: pyflakes<3.3.0,>=3.2.0; extra == "pyflakes"
40
+ Provides-Extra: pylint
41
+ Requires-Dist: pylint<4,>=3.1; extra == "pylint"
42
+ Provides-Extra: rope
43
+ Requires-Dist: rope>=1.11.0; extra == "rope"
44
+ Provides-Extra: yapf
45
+ Requires-Dist: yapf>=0.33.0; extra == "yapf"
46
+ Requires-Dist: whatthepatch<2.0.0,>=1.0.2; extra == "yapf"
47
+ Provides-Extra: websockets
48
+ Requires-Dist: websockets>=10.3; extra == "websockets"
49
+ Provides-Extra: test
50
+ Requires-Dist: pylint<4,>=3.1; extra == "test"
51
+ Requires-Dist: pytest; extra == "test"
52
+ Requires-Dist: pytest-cov; extra == "test"
53
+ Requires-Dist: coverage; extra == "test"
54
+ Requires-Dist: numpy; extra == "test"
55
+ Requires-Dist: pandas; extra == "test"
56
+ Requires-Dist: matplotlib; extra == "test"
57
+ Requires-Dist: pyqt5; extra == "test"
58
+ Requires-Dist: flaky; extra == "test"
59
+ Dynamic: license-file
60
+
61
+ # Python LSP Server
62
+
63
+ [![image](https://github.com/python-ls/python-ls/workflows/Linux%20tests/badge.svg)](https://github.com/python-ls/python-ls/actions?query=workflow%3A%22Linux+tests%22) [![image](https://github.com/python-ls/python-ls/workflows/Mac%20tests/badge.svg)](https://github.com/python-ls/python-ls/actions?query=workflow%3A%22Mac+tests%22) [![image](https://github.com/python-ls/python-ls/workflows/Windows%20tests/badge.svg)](https://github.com/python-ls/python-ls/actions?query=workflow%3A%22Windows+tests%22) [![image](https://img.shields.io/github/license/python-ls/python-ls.svg)](https://github.com/python-ls/python-ls/blob/master/LICENSE)
64
+
65
+ A Python 3.8+ implementation of the [Language Server Protocol](https://github.com/Microsoft/language-server-protocol).
66
+ (Note: versions <1.4 should still work with Python 3.6)
67
+
68
+ ## Installation
69
+
70
+ The base language server requires [Jedi](https://github.com/davidhalter/jedi) to provide Completions, Definitions, Hover, References, Signature Help, and Symbols:
71
+
72
+ ```
73
+ pip install python-lsp-server
74
+ ```
75
+ This will expose the command `pylsp` on your PATH. Confirm that installation succeeded by running `pylsp --help`.
76
+
77
+ If the respective dependencies are found, the following optional providers will be enabled:
78
+ - [Rope](https://github.com/python-rope/rope) for Completions and renaming
79
+ - [Pyflakes](https://github.com/PyCQA/pyflakes) linter to detect various errors
80
+ - [McCabe](https://github.com/PyCQA/mccabe) linter for complexity checking
81
+ - [pycodestyle](https://github.com/PyCQA/pycodestyle) linter for style checking
82
+ - [pydocstyle](https://github.com/PyCQA/pydocstyle) linter for docstring style checking (disabled by default)
83
+ - [autopep8](https://github.com/hhatto/autopep8) for code formatting
84
+ - [YAPF](https://github.com/google/yapf) for code formatting (preferred over autopep8)
85
+ - [flake8](https://github.com/pycqa/flake8) for error checking (disabled by default)
86
+ - [pylint](https://github.com/PyCQA/pylint) for code linting (disabled by default)
87
+
88
+ Optional providers can be installed using the `extras` syntax. To install [YAPF](https://github.com/google/yapf) formatting for example:
89
+
90
+ ```
91
+ pip install "python-lsp-server[yapf]"
92
+ ```
93
+
94
+ All optional providers can be installed using:
95
+
96
+ ```
97
+ pip install "python-lsp-server[all]"
98
+ ```
99
+
100
+ If you get an error similar to `'install_requires' must be a string or list of strings` then please upgrade setuptools before trying again.
101
+
102
+ ```
103
+ pip install -U setuptools
104
+ ```
105
+
106
+ ### Windows and Linux installation
107
+
108
+ If you use Anaconda/Miniconda, you can install `python-lsp-server` using this conda command
109
+
110
+ ```
111
+ conda install -c conda-forge python-lsp-server
112
+ ```
113
+
114
+ Python-lsp-server is available in the repos of every major Linux distribution, and it is usually called `python-lsp-server` or `python3-pylsp`.
115
+
116
+ For example, here is how to install it in Debian and Debian-based distributions (E.g. Ubuntu, Pop!_OS, Linux Mint)
117
+
118
+ ```
119
+ sudo apt-get install python3-pylsp
120
+ ```
121
+
122
+ or Fedora Linux
123
+
124
+ ```
125
+ sudo dnf install python3-lsp-server
126
+ ```
127
+
128
+ or Arch Linux
129
+
130
+ ```
131
+ sudo pacman -S python-lsp-server
132
+ ````
133
+
134
+ Only on Alpine Linux the package is named differently. You can install it there by typing this command in your terminal:
135
+
136
+ ```
137
+ apk add py3-lsp-server
138
+ ```
139
+
140
+ ### 3rd Party Plugins
141
+
142
+ Installing these plugins will add extra functionality to the language server:
143
+
144
+ - [pylsp-mypy](https://github.com/Richardk2n/pylsp-mypy): [MyPy](http://mypy-lang.org/) type checking for Python >=3.8.
145
+ - [python-lsp-isort](https://github.com/chantera/python-lsp-isort): code formatting using [isort](https://github.com/PyCQA/isort) (automatic import sorting).
146
+ - [python-lsp-black](https://github.com/python-lsp/python-lsp-black): code formatting using [Black](https://github.com/psf/black).
147
+ - [pyls-memestra](https://github.com/QuantStack/pyls-memestra): detecting the use of deprecated APIs.
148
+ - [pylsp-rope](https://github.com/python-rope/pylsp-rope): Extended refactoring capabilities using [Rope](https://github.com/python-rope/rope).
149
+ - [python-lsp-ruff](https://github.com/python-lsp/python-lsp-ruff): Extensive and fast linting using [ruff](https://github.com/charliermarsh/ruff).
150
+
151
+ Please see the above repositories for examples on how to write plugins for the Python LSP Server.
152
+
153
+ [cookiecutter-pylsp-plugin](https://github.com/python-lsp/cookiecutter-pylsp-plugin) is a [cookiecutter](https://cookiecutter.readthedocs.io/) template for setting up a basic plugin project for python-lsp-server. It documents all the essentials you need to know to kick start your own plugin project.
154
+
155
+ Please file an issue if you require assistance writing a plugin.
156
+
157
+ ## Configuration
158
+
159
+ Like all language servers, configuration can be passed from the client that talks to this server (i.e. your editor/IDE or other tool that has the same purpose). The details of how this is done depend on the editor or plugin that you are using to communicate with `python-lsp-server`. The configuration options available at that level are documented in [`CONFIGURATION.md`](https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md).
160
+
161
+ `python-lsp-server` depends on other tools, like flake8 and pycodestyle. These tools can be configured via settings passed from the client (as above), or alternatively from other configuration sources. The following sources are available:
162
+
163
+ - `pycodestyle`: discovered in `~/.config/pycodestyle`, `setup.cfg`, `tox.ini` and `pycodestyle.cfg`.
164
+ - `flake8`: discovered in `.flake8`, `setup.cfg` and `tox.ini`
165
+
166
+ The default configuration sources are `pycodestyle` and `pyflakes`. If you would like to use `flake8`, you will need to:
167
+
168
+ 1. Disable `pycodestyle`, `mccabe`, and `pyflakes`, by setting their corresponding `enabled` configurations, e.g. `pylsp.plugins.pycodestyle.enabled`, to `false`. This will prevent duplicate linting messages as flake8 includes these tools.
169
+ 1. Set `pylsp.plugins.flake8.enabled` to `true`.
170
+ 1. Change the `pylsp.configurationSources` setting (in the value passed in from your client) to `['flake8']` in order to use the flake8 configuration instead.
171
+
172
+ The configuration options available in these config files (`setup.cfg` etc) are documented in the relevant tools:
173
+
174
+ - [flake8 configuration](https://flake8.pycqa.org/en/latest/user/configuration.html)
175
+ - [pycodestyle configuration](https://pycodestyle.pycqa.org/en/latest/intro.html#configuration)
176
+
177
+ 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.
178
+
179
+ As an example, to change the list of errors that pycodestyle will ignore, assuming you are using the `pycodestyle` configuration source (the default), you can:
180
+
181
+ 1. Add the following to your ~/.config/pycodestyle:
182
+
183
+ ```
184
+ [pycodestyle]
185
+ ignore = E226,E302,E41
186
+ ```
187
+
188
+ 2. Set the `pylsp.plugins.pycodestyle.ignore` config value from your editor
189
+ 3. Same as 1, but add to `setup.cfg` file in the root of the project.
190
+
191
+
192
+ Python LSP Server can communicate over WebSockets when configured as follows:
193
+
194
+ ```
195
+ pylsp --ws --port [port]
196
+ ```
197
+
198
+ The following libraries are required for Web Sockets support:
199
+ - [websockets](https://websockets.readthedocs.io/en/stable/) for Python LSP Server Web sockets using websockets library. refer [Websockets installation](https://websockets.readthedocs.io/en/stable/intro/index.html#installation) for more details
200
+
201
+ You can install this dependency with command below:
202
+
203
+ ```
204
+ pip install 'python-lsp-server[websockets]'
205
+ ```
206
+
207
+ ## LSP Server Features
208
+
209
+ * Auto Completion
210
+ * [Autoimport](docs/autoimport.md)
211
+ * Code Linting
212
+ * Code actions
213
+ * Signature Help
214
+ * Go to definition
215
+ * Hover
216
+ * Find References
217
+ * Document Symbols
218
+ * Document Formatting
219
+ * Code folding
220
+ * Multiple workspaces
221
+
222
+ ## Development
223
+
224
+ Dev install
225
+
226
+ ```
227
+ # (optional) create conda env
228
+ conda create --name python-lsp-server python=3.11 -y
229
+ conda activate python-lsp-server
230
+
231
+ pip install -e ".[all,websockets,test]"
232
+ ```
233
+
234
+ Run server with ws
235
+
236
+ ```
237
+ pylsp --ws -v # Info level logging
238
+ pylsp --ws -vv # Debug level logging
239
+ ```
240
+
241
+ To run the test suite:
242
+
243
+ ```sh
244
+ # requires: pip install ".[test]" (see above)
245
+ pytest
246
+ ```
247
+
248
+ Running ruff as a linter and code formatter on the repo:
249
+ ```sh
250
+ ruff check . # linter
251
+ ruff check --fix . # fix all auto-fixable lint issues
252
+ ruff format . # format the document
253
+ ```
254
+
255
+ After adding configuration options to `schema.json`, refresh the `CONFIGURATION.md` file with
256
+
257
+ ```
258
+ python scripts/jsonschema2md.py pylsp/config/schema.json CONFIGURATION.md
259
+ ```
260
+
261
+ ## License
262
+
263
+ This project is made available under the MIT License.
@@ -0,0 +1,203 @@
1
+ # Python LSP Server
2
+
3
+ [![image](https://github.com/python-ls/python-ls/workflows/Linux%20tests/badge.svg)](https://github.com/python-ls/python-ls/actions?query=workflow%3A%22Linux+tests%22) [![image](https://github.com/python-ls/python-ls/workflows/Mac%20tests/badge.svg)](https://github.com/python-ls/python-ls/actions?query=workflow%3A%22Mac+tests%22) [![image](https://github.com/python-ls/python-ls/workflows/Windows%20tests/badge.svg)](https://github.com/python-ls/python-ls/actions?query=workflow%3A%22Windows+tests%22) [![image](https://img.shields.io/github/license/python-ls/python-ls.svg)](https://github.com/python-ls/python-ls/blob/master/LICENSE)
4
+
5
+ A Python 3.8+ implementation of the [Language Server Protocol](https://github.com/Microsoft/language-server-protocol).
6
+ (Note: versions <1.4 should still work with Python 3.6)
7
+
8
+ ## Installation
9
+
10
+ The base language server requires [Jedi](https://github.com/davidhalter/jedi) to provide Completions, Definitions, Hover, References, Signature Help, and Symbols:
11
+
12
+ ```
13
+ pip install python-lsp-server
14
+ ```
15
+ This will expose the command `pylsp` on your PATH. Confirm that installation succeeded by running `pylsp --help`.
16
+
17
+ If the respective dependencies are found, the following optional providers will be enabled:
18
+ - [Rope](https://github.com/python-rope/rope) for Completions and renaming
19
+ - [Pyflakes](https://github.com/PyCQA/pyflakes) linter to detect various errors
20
+ - [McCabe](https://github.com/PyCQA/mccabe) linter for complexity checking
21
+ - [pycodestyle](https://github.com/PyCQA/pycodestyle) linter for style checking
22
+ - [pydocstyle](https://github.com/PyCQA/pydocstyle) linter for docstring style checking (disabled by default)
23
+ - [autopep8](https://github.com/hhatto/autopep8) for code formatting
24
+ - [YAPF](https://github.com/google/yapf) for code formatting (preferred over autopep8)
25
+ - [flake8](https://github.com/pycqa/flake8) for error checking (disabled by default)
26
+ - [pylint](https://github.com/PyCQA/pylint) for code linting (disabled by default)
27
+
28
+ Optional providers can be installed using the `extras` syntax. To install [YAPF](https://github.com/google/yapf) formatting for example:
29
+
30
+ ```
31
+ pip install "python-lsp-server[yapf]"
32
+ ```
33
+
34
+ All optional providers can be installed using:
35
+
36
+ ```
37
+ pip install "python-lsp-server[all]"
38
+ ```
39
+
40
+ If you get an error similar to `'install_requires' must be a string or list of strings` then please upgrade setuptools before trying again.
41
+
42
+ ```
43
+ pip install -U setuptools
44
+ ```
45
+
46
+ ### Windows and Linux installation
47
+
48
+ If you use Anaconda/Miniconda, you can install `python-lsp-server` using this conda command
49
+
50
+ ```
51
+ conda install -c conda-forge python-lsp-server
52
+ ```
53
+
54
+ Python-lsp-server is available in the repos of every major Linux distribution, and it is usually called `python-lsp-server` or `python3-pylsp`.
55
+
56
+ For example, here is how to install it in Debian and Debian-based distributions (E.g. Ubuntu, Pop!_OS, Linux Mint)
57
+
58
+ ```
59
+ sudo apt-get install python3-pylsp
60
+ ```
61
+
62
+ or Fedora Linux
63
+
64
+ ```
65
+ sudo dnf install python3-lsp-server
66
+ ```
67
+
68
+ or Arch Linux
69
+
70
+ ```
71
+ sudo pacman -S python-lsp-server
72
+ ````
73
+
74
+ Only on Alpine Linux the package is named differently. You can install it there by typing this command in your terminal:
75
+
76
+ ```
77
+ apk add py3-lsp-server
78
+ ```
79
+
80
+ ### 3rd Party Plugins
81
+
82
+ Installing these plugins will add extra functionality to the language server:
83
+
84
+ - [pylsp-mypy](https://github.com/Richardk2n/pylsp-mypy): [MyPy](http://mypy-lang.org/) type checking for Python >=3.8.
85
+ - [python-lsp-isort](https://github.com/chantera/python-lsp-isort): code formatting using [isort](https://github.com/PyCQA/isort) (automatic import sorting).
86
+ - [python-lsp-black](https://github.com/python-lsp/python-lsp-black): code formatting using [Black](https://github.com/psf/black).
87
+ - [pyls-memestra](https://github.com/QuantStack/pyls-memestra): detecting the use of deprecated APIs.
88
+ - [pylsp-rope](https://github.com/python-rope/pylsp-rope): Extended refactoring capabilities using [Rope](https://github.com/python-rope/rope).
89
+ - [python-lsp-ruff](https://github.com/python-lsp/python-lsp-ruff): Extensive and fast linting using [ruff](https://github.com/charliermarsh/ruff).
90
+
91
+ Please see the above repositories for examples on how to write plugins for the Python LSP Server.
92
+
93
+ [cookiecutter-pylsp-plugin](https://github.com/python-lsp/cookiecutter-pylsp-plugin) is a [cookiecutter](https://cookiecutter.readthedocs.io/) template for setting up a basic plugin project for python-lsp-server. It documents all the essentials you need to know to kick start your own plugin project.
94
+
95
+ Please file an issue if you require assistance writing a plugin.
96
+
97
+ ## Configuration
98
+
99
+ Like all language servers, configuration can be passed from the client that talks to this server (i.e. your editor/IDE or other tool that has the same purpose). The details of how this is done depend on the editor or plugin that you are using to communicate with `python-lsp-server`. The configuration options available at that level are documented in [`CONFIGURATION.md`](https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md).
100
+
101
+ `python-lsp-server` depends on other tools, like flake8 and pycodestyle. These tools can be configured via settings passed from the client (as above), or alternatively from other configuration sources. The following sources are available:
102
+
103
+ - `pycodestyle`: discovered in `~/.config/pycodestyle`, `setup.cfg`, `tox.ini` and `pycodestyle.cfg`.
104
+ - `flake8`: discovered in `.flake8`, `setup.cfg` and `tox.ini`
105
+
106
+ The default configuration sources are `pycodestyle` and `pyflakes`. If you would like to use `flake8`, you will need to:
107
+
108
+ 1. Disable `pycodestyle`, `mccabe`, and `pyflakes`, by setting their corresponding `enabled` configurations, e.g. `pylsp.plugins.pycodestyle.enabled`, to `false`. This will prevent duplicate linting messages as flake8 includes these tools.
109
+ 1. Set `pylsp.plugins.flake8.enabled` to `true`.
110
+ 1. Change the `pylsp.configurationSources` setting (in the value passed in from your client) to `['flake8']` in order to use the flake8 configuration instead.
111
+
112
+ The configuration options available in these config files (`setup.cfg` etc) are documented in the relevant tools:
113
+
114
+ - [flake8 configuration](https://flake8.pycqa.org/en/latest/user/configuration.html)
115
+ - [pycodestyle configuration](https://pycodestyle.pycqa.org/en/latest/intro.html#configuration)
116
+
117
+ 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.
118
+
119
+ As an example, to change the list of errors that pycodestyle will ignore, assuming you are using the `pycodestyle` configuration source (the default), you can:
120
+
121
+ 1. Add the following to your ~/.config/pycodestyle:
122
+
123
+ ```
124
+ [pycodestyle]
125
+ ignore = E226,E302,E41
126
+ ```
127
+
128
+ 2. Set the `pylsp.plugins.pycodestyle.ignore` config value from your editor
129
+ 3. Same as 1, but add to `setup.cfg` file in the root of the project.
130
+
131
+
132
+ Python LSP Server can communicate over WebSockets when configured as follows:
133
+
134
+ ```
135
+ pylsp --ws --port [port]
136
+ ```
137
+
138
+ The following libraries are required for Web Sockets support:
139
+ - [websockets](https://websockets.readthedocs.io/en/stable/) for Python LSP Server Web sockets using websockets library. refer [Websockets installation](https://websockets.readthedocs.io/en/stable/intro/index.html#installation) for more details
140
+
141
+ You can install this dependency with command below:
142
+
143
+ ```
144
+ pip install 'python-lsp-server[websockets]'
145
+ ```
146
+
147
+ ## LSP Server Features
148
+
149
+ * Auto Completion
150
+ * [Autoimport](docs/autoimport.md)
151
+ * Code Linting
152
+ * Code actions
153
+ * Signature Help
154
+ * Go to definition
155
+ * Hover
156
+ * Find References
157
+ * Document Symbols
158
+ * Document Formatting
159
+ * Code folding
160
+ * Multiple workspaces
161
+
162
+ ## Development
163
+
164
+ Dev install
165
+
166
+ ```
167
+ # (optional) create conda env
168
+ conda create --name python-lsp-server python=3.11 -y
169
+ conda activate python-lsp-server
170
+
171
+ pip install -e ".[all,websockets,test]"
172
+ ```
173
+
174
+ Run server with ws
175
+
176
+ ```
177
+ pylsp --ws -v # Info level logging
178
+ pylsp --ws -vv # Debug level logging
179
+ ```
180
+
181
+ To run the test suite:
182
+
183
+ ```sh
184
+ # requires: pip install ".[test]" (see above)
185
+ pytest
186
+ ```
187
+
188
+ Running ruff as a linter and code formatter on the repo:
189
+ ```sh
190
+ ruff check . # linter
191
+ ruff check --fix . # fix all auto-fixable lint issues
192
+ ruff format . # format the document
193
+ ```
194
+
195
+ After adding configuration options to `schema.json`, refresh the `CONFIGURATION.md` file with
196
+
197
+ ```
198
+ python scripts/jsonschema2md.py pylsp/config/schema.json CONFIGURATION.md
199
+ ```
200
+
201
+ ## License
202
+
203
+ This project is made available under the MIT License.