deepnote-python-lsp-server 0.0.0__py2.py3-none-any.whl

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 (43) hide show
  1. deepnote_python_lsp_server-0.0.0.dist-info/METADATA +263 -0
  2. deepnote_python_lsp_server-0.0.0.dist-info/RECORD +43 -0
  3. deepnote_python_lsp_server-0.0.0.dist-info/WHEEL +6 -0
  4. deepnote_python_lsp_server-0.0.0.dist-info/entry_points.txt +24 -0
  5. deepnote_python_lsp_server-0.0.0.dist-info/licenses/LICENSE +22 -0
  6. deepnote_python_lsp_server-0.0.0.dist-info/top_level.txt +1 -0
  7. pylsp/__init__.py +33 -0
  8. pylsp/__main__.py +132 -0
  9. pylsp/_utils.py +325 -0
  10. pylsp/config/__init__.py +2 -0
  11. pylsp/config/config.py +202 -0
  12. pylsp/config/flake8_conf.py +64 -0
  13. pylsp/config/pycodestyle_conf.py +34 -0
  14. pylsp/config/source.py +88 -0
  15. pylsp/hookspecs.py +140 -0
  16. pylsp/lsp.py +115 -0
  17. pylsp/plugins/__init__.py +2 -0
  18. pylsp/plugins/_resolvers.py +132 -0
  19. pylsp/plugins/_rope_task_handle.py +106 -0
  20. pylsp/plugins/autopep8_format.py +95 -0
  21. pylsp/plugins/definition.py +84 -0
  22. pylsp/plugins/flake8_lint.py +243 -0
  23. pylsp/plugins/folding.py +210 -0
  24. pylsp/plugins/highlight.py +36 -0
  25. pylsp/plugins/hover.py +57 -0
  26. pylsp/plugins/jedi_completion.py +318 -0
  27. pylsp/plugins/jedi_rename.py +56 -0
  28. pylsp/plugins/mccabe_lint.py +56 -0
  29. pylsp/plugins/preload_imports.py +38 -0
  30. pylsp/plugins/pycodestyle_lint.py +113 -0
  31. pylsp/plugins/pydocstyle_lint.py +127 -0
  32. pylsp/plugins/pyflakes_lint.py +97 -0
  33. pylsp/plugins/pylint_lint.py +367 -0
  34. pylsp/plugins/references.py +33 -0
  35. pylsp/plugins/rope_autoimport.py +407 -0
  36. pylsp/plugins/rope_completion.py +161 -0
  37. pylsp/plugins/signature.py +81 -0
  38. pylsp/plugins/symbols.py +214 -0
  39. pylsp/plugins/yapf_format.py +199 -0
  40. pylsp/python_lsp.py +921 -0
  41. pylsp/text_edit.py +97 -0
  42. pylsp/uris.py +139 -0
  43. pylsp/workspace.py +730 -0
@@ -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,43 @@
1
+ deepnote_python_lsp_server-0.0.0.dist-info/licenses/LICENSE,sha256=rsArR45X85WuRYArKqcPz5m7o-q_TNcAwGXNYqfZKhs,1147
2
+ pylsp/__init__.py,sha256=pp21AWL0whEQYBt-9_tsAH1Mgb985QScnzSgqx3poTI,762
3
+ pylsp/__main__.py,sha256=yPDx5h3vuXTIlxAEmkyitIFXyE_WF8FFaO9KJ6qxjMc,3893
4
+ pylsp/_utils.py,sha256=sG2XzeFazCAd1d1DDbXS1c-QxHWObcNM71kLI4SZ5dg,9866
5
+ pylsp/hookspecs.py,sha256=dJtBbVJrXgPOlTGZvVOoweBqNS_-sIWWaVpQyiSH0MQ,2623
6
+ pylsp/lsp.py,sha256=UNoXmPraDwcgD7KsWjuWqTbi1NBBN7fOpDBL_vkn__A,2050
7
+ pylsp/python_lsp.py,sha256=mp8lz7wkkfiKbQmhbznVDJabYA3Q-FYqpPkoBS9LmOw,36356
8
+ pylsp/text_edit.py,sha256=0CKXPieuvOenmerfeb2Rgt-YSuwqORSkracSv8dxnlg,2768
9
+ pylsp/uris.py,sha256=rYUMuLNj9ZdD-ttI-X5a5NZfszo58AzDy6mcUQmmKiM,3834
10
+ pylsp/workspace.py,sha256=vEi0sY9g02EnYEqevuxlEfK5ES5LvOfiFEARpDiG_cI,24044
11
+ pylsp/config/__init__.py,sha256=bDWxRjmELPCVGy243_0kNrG7PttyZsv_eZ9JTKQrU1E,105
12
+ pylsp/config/config.py,sha256=AkkKZVHdmILZVP93dI1OQ5DtlHYpBzyyfYl9ruuKmlQ,6956
13
+ pylsp/config/flake8_conf.py,sha256=PvNkDnckn5lTr5q-LieIAKAEXoXDnzeGdApFNdMfp4k,2370
14
+ pylsp/config/pycodestyle_conf.py,sha256=QeTq5yEXIMidIPs2pjuE450X3VudUu9F3DTHHCFaASk,1268
15
+ pylsp/config/source.py,sha256=PiKrKgsRmROZp-qRbzpGXNkKSlNF-Y-d94IygK4cSCg,2753
16
+ pylsp/plugins/__init__.py,sha256=bDWxRjmELPCVGy243_0kNrG7PttyZsv_eZ9JTKQrU1E,105
17
+ pylsp/plugins/_resolvers.py,sha256=pBFkf7OGHfjpnnLKt75K_4asQc8w5z5zEvv9crcO8pE,4390
18
+ pylsp/plugins/_rope_task_handle.py,sha256=Z-CfeK6rH-RYb5pAkqtDy0fwBTd3cwfbTvH6OI9-psk,2887
19
+ pylsp/plugins/autopep8_format.py,sha256=iLJ9FYbH_7NcyyeKpXVNAKLCzG5-FnWsgE13iidb2IE,3185
20
+ pylsp/plugins/definition.py,sha256=SJB9tSllwhBE21RvbkXZWN39qpmfu3ke4ZgeWjgTf2M,2670
21
+ pylsp/plugins/flake8_lint.py,sha256=wBv9P9q6Pz0fA6G_mpmA4c3hqv6GJBGBDl7--NV4Ip8,8335
22
+ pylsp/plugins/folding.py,sha256=tMudxoyr5gp2HJ6P06tJGkSOVCBbI2CgBpVELkm1o-E,7035
23
+ pylsp/plugins/highlight.py,sha256=VzBDNJWrbRexiCYA5a6-RWRuipaxC-BLRhmT4k-ryu4,1100
24
+ pylsp/plugins/hover.py,sha256=13tPg3acB5IBJQGgX27UqhcAUOgvnKQkrzZiQ4MwYDs,1720
25
+ pylsp/plugins/jedi_completion.py,sha256=cBaXqzgZac0mCBBCidBXj79qFhEC1wm-0WG2v-HR67w,11015
26
+ pylsp/plugins/jedi_rename.py,sha256=JKIb7lcLHkIgJ2k83SZmgDr0fTxMG_jpEhfS_gfXTuI,1908
27
+ pylsp/plugins/mccabe_lint.py,sha256=AqiojhZAqK3eXW6LXFXZqg3uCawept5Qod7CoaX9omM,1826
28
+ pylsp/plugins/preload_imports.py,sha256=mch9mNv9lOOBBJe_JQiDI6cGY727NwFqKTCPPPTRrpY,1291
29
+ pylsp/plugins/pycodestyle_lint.py,sha256=1nECd4jHeuS1cwIdgIjDzYVczj4xDGbWqDCaiN_ABa4,4011
30
+ pylsp/plugins/pydocstyle_lint.py,sha256=EDUaKhjibqs1Kr5L8ECoDm6VCNbnuP8FzhjBJo1iQkA,4172
31
+ pylsp/plugins/pyflakes_lint.py,sha256=n0KTtmKdZindHqHFhNPEgqCPrFKDD2TI0LLUbJvDiX0,3137
32
+ pylsp/plugins/pylint_lint.py,sha256=qrLx8JTU9AX4D6eKFGPfiGMf9K6T8yQ3VAmxhBXHMuU,12372
33
+ pylsp/plugins/references.py,sha256=sXCBw9qr-02yIbYO40YSAfaW_ENVY7X7s07xNeezlmg,1036
34
+ pylsp/plugins/rope_autoimport.py,sha256=tTMRp9hfU3qm8VbuqA7Gx8xzdw3TE3HMjzRqMltJwIE,13357
35
+ pylsp/plugins/rope_completion.py,sha256=MmM8qa9UiAEVGigHW9plKUMToT7iiKlIqGXW8-NdGbg,5913
36
+ pylsp/plugins/signature.py,sha256=j_A_5uka816uyRAZW-Go1khHTY43MT0j-10d58NHf8s,2592
37
+ pylsp/plugins/symbols.py,sha256=z9g6ghleEDFftyH4slEf-nm8VjFSbb-QMhG_lTgAvRo,7944
38
+ pylsp/plugins/yapf_format.py,sha256=Ds5WXxeXQaQqoiXwXmKe8sXzlLrsjQPGzyBk7HW8B5k,6785
39
+ deepnote_python_lsp_server-0.0.0.dist-info/METADATA,sha256=lPnErN_cG9VTp_3bs7P6eMCRY5bquw7jG_nH-97kIho,10947
40
+ deepnote_python_lsp_server-0.0.0.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
41
+ deepnote_python_lsp_server-0.0.0.dist-info/entry_points.txt,sha256=arJtnji88DE7OhG5W361q_RtIV5eQpAo0A3PF_kegg0,860
42
+ deepnote_python_lsp_server-0.0.0.dist-info/top_level.txt,sha256=LamqoHzmagL8tkMqWx8FqE2ByHDcRKZwh7OJEyvru14,6
43
+ deepnote_python_lsp_server-0.0.0.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any
6
+
@@ -0,0 +1,24 @@
1
+ [console_scripts]
2
+ pylsp = pylsp.__main__:main
3
+
4
+ [pylsp]
5
+ autopep8 = pylsp.plugins.autopep8_format
6
+ flake8 = pylsp.plugins.flake8_lint
7
+ folding = pylsp.plugins.folding
8
+ jedi_completion = pylsp.plugins.jedi_completion
9
+ jedi_definition = pylsp.plugins.definition
10
+ jedi_highlight = pylsp.plugins.highlight
11
+ jedi_hover = pylsp.plugins.hover
12
+ jedi_references = pylsp.plugins.references
13
+ jedi_rename = pylsp.plugins.jedi_rename
14
+ jedi_signature_help = pylsp.plugins.signature
15
+ jedi_symbols = pylsp.plugins.symbols
16
+ mccabe = pylsp.plugins.mccabe_lint
17
+ preload = pylsp.plugins.preload_imports
18
+ pycodestyle = pylsp.plugins.pycodestyle_lint
19
+ pydocstyle = pylsp.plugins.pydocstyle_lint
20
+ pyflakes = pylsp.plugins.pyflakes_lint
21
+ pylint = pylsp.plugins.pylint_lint
22
+ rope_autoimport = pylsp.plugins.rope_autoimport
23
+ rope_completion = pylsp.plugins.rope_completion
24
+ yapf = pylsp.plugins.yapf_format
@@ -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.
pylsp/__init__.py ADDED
@@ -0,0 +1,33 @@
1
+ # Copyright 2017-2020 Palantir Technologies, Inc.
2
+ # Copyright 2021- Python Language Server Contributors.
3
+
4
+ import os
5
+
6
+ import pluggy
7
+
8
+ from . import _version
9
+ from ._version import __version__
10
+
11
+
12
+ def convert_version_info(version: str) -> (int, ..., str):
13
+ version_info = version.split(".")
14
+ for i, v in enumerate(version_info):
15
+ try:
16
+ version_info[i] = int(v)
17
+ except ValueError:
18
+ version_info[i] = v.split("+")[0]
19
+ version_info = version_info[: i + 1]
20
+ break
21
+
22
+ return tuple(version_info)
23
+
24
+
25
+ _version.VERSION_INFO = convert_version_info(__version__)
26
+
27
+ PYLSP = "pylsp"
28
+ IS_WIN = os.name == "nt"
29
+
30
+ hookspec = pluggy.HookspecMarker(PYLSP)
31
+ hookimpl = pluggy.HookimplMarker(PYLSP)
32
+
33
+ __all__ = ("__version__",)
pylsp/__main__.py ADDED
@@ -0,0 +1,132 @@
1
+ # Copyright 2017-2020 Palantir Technologies, Inc.
2
+ # Copyright 2021- Python Language Server Contributors.
3
+
4
+ import argparse
5
+ import logging
6
+ import logging.config
7
+ import sys
8
+ import time
9
+
10
+ try:
11
+ import ujson as json
12
+ except Exception:
13
+ import json
14
+
15
+ from ._version import __version__
16
+ from .python_lsp import (
17
+ PythonLSPServer,
18
+ start_io_lang_server,
19
+ start_tcp_lang_server,
20
+ start_ws_lang_server,
21
+ )
22
+
23
+ LOG_FORMAT = "%(asctime)s {0} - %(levelname)s - %(name)s - %(message)s".format(
24
+ time.localtime().tm_zone
25
+ )
26
+
27
+
28
+ def add_arguments(parser) -> None:
29
+ parser.description = "Python Language Server"
30
+
31
+ parser.add_argument(
32
+ "--tcp", action="store_true", help="Use TCP server instead of stdio"
33
+ )
34
+ parser.add_argument(
35
+ "--ws", action="store_true", help="Use Web Sockets server instead of stdio"
36
+ )
37
+ parser.add_argument("--host", default="127.0.0.1", help="Bind to this address")
38
+ parser.add_argument("--port", type=int, default=2087, help="Bind to this port")
39
+ parser.add_argument(
40
+ "--check-parent-process",
41
+ action="store_true",
42
+ help="Check whether parent process is still alive using os.kill(ppid, 0) "
43
+ "and auto shut down language server process when parent process is not alive."
44
+ "Note that this may not work on a Windows machine.",
45
+ )
46
+
47
+ log_group = parser.add_mutually_exclusive_group()
48
+ log_group.add_argument(
49
+ "--log-config", help="Path to a JSON file containing Python logging config."
50
+ )
51
+ log_group.add_argument(
52
+ "--log-file",
53
+ help="Redirect logs to the given file instead of writing to stderr."
54
+ "Has no effect if used with --log-config.",
55
+ )
56
+
57
+ parser.add_argument(
58
+ "-v",
59
+ "--verbose",
60
+ action="count",
61
+ default=0,
62
+ help="Increase verbosity of log output, overrides log config file",
63
+ )
64
+
65
+ parser.add_argument(
66
+ "-V", "--version", action="version", version="%(prog)s v" + __version__
67
+ )
68
+
69
+
70
+ def main() -> None:
71
+ parser = argparse.ArgumentParser()
72
+ add_arguments(parser)
73
+ args = parser.parse_args()
74
+ _configure_logger(args.verbose, args.log_config, args.log_file)
75
+
76
+ if args.tcp:
77
+ while True:
78
+ start_tcp_lang_server(
79
+ args.host, args.port, args.check_parent_process, PythonLSPServer
80
+ )
81
+ time.sleep(0.500)
82
+ elif args.ws:
83
+ start_ws_lang_server(args.port, args.check_parent_process, PythonLSPServer)
84
+ else:
85
+ stdin, stdout = _binary_stdio()
86
+ start_io_lang_server(stdin, stdout, args.check_parent_process, PythonLSPServer)
87
+
88
+
89
+ def _binary_stdio():
90
+ """Construct binary stdio streams (not text mode).
91
+
92
+ This seems to be different for Window/Unix Python2/3, so going by:
93
+ https://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin
94
+ """
95
+ stdin, stdout = sys.stdin.buffer, sys.stdout.buffer
96
+ return stdin, stdout
97
+
98
+
99
+ def _configure_logger(verbose=0, log_config=None, log_file=None) -> None:
100
+ root_logger = logging.root
101
+
102
+ if log_config:
103
+ with open(log_config, "r", encoding="utf-8") as f:
104
+ logging.config.dictConfig(json.load(f))
105
+ else:
106
+ formatter = logging.Formatter(LOG_FORMAT)
107
+ if log_file:
108
+ log_handler = logging.handlers.RotatingFileHandler(
109
+ log_file,
110
+ mode="a",
111
+ maxBytes=50 * 1024 * 1024,
112
+ backupCount=10,
113
+ encoding=None,
114
+ delay=0,
115
+ )
116
+ else:
117
+ log_handler = logging.StreamHandler()
118
+ log_handler.setFormatter(formatter)
119
+ root_logger.addHandler(log_handler)
120
+
121
+ if verbose == 0:
122
+ level = logging.WARNING
123
+ elif verbose == 1:
124
+ level = logging.INFO
125
+ elif verbose >= 2:
126
+ level = logging.DEBUG
127
+
128
+ root_logger.setLevel(level)
129
+
130
+
131
+ if __name__ == "__main__":
132
+ main()