deepnote-python-lsp-server 1.13.1rc2__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 (46) hide show
  1. deepnote_python_lsp_server-1.13.1rc2.dist-info/METADATA +264 -0
  2. deepnote_python_lsp_server-1.13.1rc2.dist-info/RECORD +46 -0
  3. deepnote_python_lsp_server-1.13.1rc2.dist-info/WHEEL +5 -0
  4. deepnote_python_lsp_server-1.13.1rc2.dist-info/entry_points.txt +25 -0
  5. deepnote_python_lsp_server-1.13.1rc2.dist-info/licenses/LICENSE +22 -0
  6. deepnote_python_lsp_server-1.13.1rc2.dist-info/top_level.txt +1 -0
  7. pylsp/__init__.py +33 -0
  8. pylsp/__main__.py +132 -0
  9. pylsp/_utils.py +418 -0
  10. pylsp/_version.py +1 -0
  11. pylsp/config/__init__.py +2 -0
  12. pylsp/config/config.py +203 -0
  13. pylsp/config/flake8_conf.py +64 -0
  14. pylsp/config/pycodestyle_conf.py +34 -0
  15. pylsp/config/source.py +88 -0
  16. pylsp/hookspecs.py +150 -0
  17. pylsp/lsp.py +115 -0
  18. pylsp/plugins/__init__.py +2 -0
  19. pylsp/plugins/_resolvers.py +132 -0
  20. pylsp/plugins/_rope_task_handle.py +107 -0
  21. pylsp/plugins/autopep8_format.py +95 -0
  22. pylsp/plugins/definition.py +84 -0
  23. pylsp/plugins/flake8_lint.py +243 -0
  24. pylsp/plugins/folding.py +210 -0
  25. pylsp/plugins/highlight.py +36 -0
  26. pylsp/plugins/hover.py +59 -0
  27. pylsp/plugins/jedi_completion.py +337 -0
  28. pylsp/plugins/jedi_rename.py +56 -0
  29. pylsp/plugins/mccabe_lint.py +56 -0
  30. pylsp/plugins/preload_imports.py +72 -0
  31. pylsp/plugins/pycodestyle_lint.py +113 -0
  32. pylsp/plugins/pydocstyle_lint.py +127 -0
  33. pylsp/plugins/pyflakes_lint.py +97 -0
  34. pylsp/plugins/pylint_lint.py +367 -0
  35. pylsp/plugins/references.py +33 -0
  36. pylsp/plugins/rope_autoimport.py +408 -0
  37. pylsp/plugins/rope_completion.py +161 -0
  38. pylsp/plugins/signature.py +81 -0
  39. pylsp/plugins/symbols.py +219 -0
  40. pylsp/plugins/type_definition.py +38 -0
  41. pylsp/plugins/yapf_format.py +199 -0
  42. pylsp/py.typed +0 -0
  43. pylsp/python_lsp.py +945 -0
  44. pylsp/text_edit.py +97 -0
  45. pylsp/uris.py +139 -0
  46. pylsp/workspace.py +791 -0
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.4
2
+ Name: deepnote-python-lsp-server
3
+ Version: 1.13.1rc2
4
+ Summary: Python Language Server for the Language Server Protocol
5
+ Author: Python Language Server Contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/deepnote/python-lsp-server
8
+ Requires-Python: >=3.9
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
+ Requires-Dist: black
18
+ Provides-Extra: all
19
+ Requires-Dist: autopep8<2.1.0,>=2.0.4; extra == "all"
20
+ Requires-Dist: flake8<8,>=7.1; extra == "all"
21
+ Requires-Dist: mccabe<0.8.0,>=0.7.0; extra == "all"
22
+ Requires-Dist: pycodestyle<2.13.0,>=2.12.0; extra == "all"
23
+ Requires-Dist: pydocstyle<6.4.0,>=6.3.0; extra == "all"
24
+ Requires-Dist: pyflakes<3.3.0,>=3.2.0; extra == "all"
25
+ Requires-Dist: pylint<4,>=3.1; extra == "all"
26
+ Requires-Dist: rope>=1.11.0; extra == "all"
27
+ Requires-Dist: yapf>=0.33.0; extra == "all"
28
+ Requires-Dist: whatthepatch<2.0.0,>=1.0.2; extra == "all"
29
+ Provides-Extra: autopep8
30
+ Requires-Dist: autopep8<2.1.0,>=2.0.4; extra == "autopep8"
31
+ Provides-Extra: flake8
32
+ Requires-Dist: flake8<8,>=7.1; extra == "flake8"
33
+ Provides-Extra: mccabe
34
+ Requires-Dist: mccabe<0.8.0,>=0.7.0; extra == "mccabe"
35
+ Provides-Extra: pycodestyle
36
+ Requires-Dist: pycodestyle<2.13.0,>=2.12.0; extra == "pycodestyle"
37
+ Provides-Extra: pydocstyle
38
+ Requires-Dist: pydocstyle<6.4.0,>=6.3.0; extra == "pydocstyle"
39
+ Provides-Extra: pyflakes
40
+ Requires-Dist: pyflakes<3.3.0,>=3.2.0; extra == "pyflakes"
41
+ Provides-Extra: pylint
42
+ Requires-Dist: pylint<4,>=3.1; extra == "pylint"
43
+ Provides-Extra: rope
44
+ Requires-Dist: rope>=1.11.0; extra == "rope"
45
+ Provides-Extra: yapf
46
+ Requires-Dist: yapf>=0.33.0; extra == "yapf"
47
+ Requires-Dist: whatthepatch<2.0.0,>=1.0.2; extra == "yapf"
48
+ Provides-Extra: websockets
49
+ Requires-Dist: websockets>=10.3; extra == "websockets"
50
+ Provides-Extra: test
51
+ Requires-Dist: pylint<4,>=3.1; extra == "test"
52
+ Requires-Dist: pytest; extra == "test"
53
+ Requires-Dist: pytest-cov; extra == "test"
54
+ Requires-Dist: coverage; extra == "test"
55
+ Requires-Dist: numpy; extra == "test"
56
+ Requires-Dist: pandas; extra == "test"
57
+ Requires-Dist: matplotlib; extra == "test"
58
+ Requires-Dist: pyqt6; extra == "test"
59
+ Requires-Dist: flaky; extra == "test"
60
+ Requires-Dist: websockets>=10.3; extra == "test"
61
+ Dynamic: license-file
62
+
63
+ # Python LSP Server
64
+
65
+ [![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)
66
+
67
+ A Python 3.9+ implementation of the [Language Server Protocol](https://github.com/Microsoft/language-server-protocol).
68
+
69
+ ## Installation
70
+
71
+ The base language server requires [Jedi](https://github.com/davidhalter/jedi) to provide Completions, Definitions, Hover, References, Signature Help, and Symbols:
72
+
73
+ ```
74
+ pip install python-lsp-server
75
+ ```
76
+ This will expose the command `pylsp` on your PATH. Confirm that installation succeeded by running `pylsp --help`.
77
+
78
+ If the respective dependencies are found, the following optional providers will be enabled:
79
+ - [Rope](https://github.com/python-rope/rope) for Completions and renaming
80
+ - [Pyflakes](https://github.com/PyCQA/pyflakes) linter to detect various errors
81
+ - [McCabe](https://github.com/PyCQA/mccabe) linter for complexity checking
82
+ - [pycodestyle](https://github.com/PyCQA/pycodestyle) linter for style checking
83
+ - [pydocstyle](https://github.com/PyCQA/pydocstyle) linter for docstring style checking (disabled by default)
84
+ - [autopep8](https://github.com/hhatto/autopep8) for code formatting
85
+ - [YAPF](https://github.com/google/yapf) for code formatting (preferred over autopep8)
86
+ - [flake8](https://github.com/pycqa/flake8) for error checking (disabled by default)
87
+ - [pylint](https://github.com/PyCQA/pylint) for code linting (disabled by default)
88
+
89
+ Optional providers can be installed using the `extras` syntax. To install [YAPF](https://github.com/google/yapf) formatting for example:
90
+
91
+ ```
92
+ pip install "python-lsp-server[yapf]"
93
+ ```
94
+
95
+ All optional providers can be installed using:
96
+
97
+ ```
98
+ pip install "python-lsp-server[all]"
99
+ ```
100
+
101
+ If you get an error similar to `'install_requires' must be a string or list of strings` then please upgrade setuptools before trying again.
102
+
103
+ ```
104
+ pip install -U setuptools
105
+ ```
106
+
107
+ ### Windows and Linux installation
108
+
109
+ If you use Anaconda/Miniconda, you can install `python-lsp-server` using this conda command
110
+
111
+ ```
112
+ conda install -c conda-forge python-lsp-server
113
+ ```
114
+
115
+ Python-lsp-server is available in the repos of every major Linux distribution, and it is usually called `python-lsp-server` or `python3-pylsp`.
116
+
117
+ For example, here is how to install it in Debian and Debian-based distributions (E.g. Ubuntu, Pop!_OS, Linux Mint)
118
+
119
+ ```
120
+ sudo apt-get install python3-pylsp
121
+ ```
122
+
123
+ or Fedora Linux
124
+
125
+ ```
126
+ sudo dnf install python3-lsp-server
127
+ ```
128
+
129
+ or Arch Linux
130
+
131
+ ```
132
+ sudo pacman -S python-lsp-server
133
+ ````
134
+
135
+ Only on Alpine Linux the package is named differently. You can install it there by typing this command in your terminal:
136
+
137
+ ```
138
+ apk add py3-lsp-server
139
+ ```
140
+
141
+ ### 3rd Party Plugins
142
+
143
+ Installing these plugins will add extra functionality to the language server:
144
+
145
+ - [pylsp-mypy](https://github.com/Richardk2n/pylsp-mypy): [MyPy](http://mypy-lang.org/) type checking for Python >=3.8.
146
+ - [python-lsp-isort](https://github.com/chantera/python-lsp-isort): code formatting using [isort](https://github.com/PyCQA/isort) (automatic import sorting).
147
+ - [python-lsp-black](https://github.com/python-lsp/python-lsp-black): code formatting using [Black](https://github.com/psf/black).
148
+ - [pyls-memestra](https://github.com/QuantStack/pyls-memestra): detecting the use of deprecated APIs.
149
+ - [pylsp-rope](https://github.com/python-rope/pylsp-rope): Extended refactoring capabilities using [Rope](https://github.com/python-rope/rope).
150
+ - [python-lsp-ruff](https://github.com/python-lsp/python-lsp-ruff): Extensive and fast linting using [ruff](https://github.com/charliermarsh/ruff).
151
+
152
+ Please see the above repositories for examples on how to write plugins for the Python LSP Server.
153
+
154
+ [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.
155
+
156
+ Please file an issue if you require assistance writing a plugin.
157
+
158
+ ## Configuration
159
+
160
+ 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).
161
+
162
+ `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:
163
+
164
+ - `pycodestyle`: discovered in `~/.config/pycodestyle`, `setup.cfg`, `tox.ini` and `pycodestyle.cfg`.
165
+ - `flake8`: discovered in `.flake8`, `setup.cfg` and `tox.ini`
166
+
167
+ The default configuration sources are `pycodestyle` and `pyflakes`. If you would like to use `flake8`, you will need to:
168
+
169
+ 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.
170
+ 1. Set `pylsp.plugins.flake8.enabled` to `true`.
171
+ 1. Change the `pylsp.configurationSources` setting (in the value passed in from your client) to `['flake8']` in order to use the flake8 configuration instead.
172
+
173
+ The configuration options available in these config files (`setup.cfg` etc) are documented in the relevant tools:
174
+
175
+ - [flake8 configuration](https://flake8.pycqa.org/en/latest/user/configuration.html)
176
+ - [pycodestyle configuration](https://pycodestyle.pycqa.org/en/latest/intro.html#configuration)
177
+
178
+ 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.
179
+
180
+ 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:
181
+
182
+ 1. Add the following to your ~/.config/pycodestyle:
183
+
184
+ ```
185
+ [pycodestyle]
186
+ ignore = E226,E302,E41
187
+ ```
188
+
189
+ 2. Set the `pylsp.plugins.pycodestyle.ignore` config value from your editor
190
+ 3. Same as 1, but add to `setup.cfg` file in the root of the project.
191
+
192
+
193
+ Python LSP Server can communicate over WebSockets when configured as follows:
194
+
195
+ ```
196
+ pylsp --ws --port [port]
197
+ ```
198
+
199
+ The following libraries are required for Web Sockets support:
200
+ - [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
201
+
202
+ You can install this dependency with command below:
203
+
204
+ ```
205
+ pip install 'python-lsp-server[websockets]'
206
+ ```
207
+
208
+ ## LSP Server Features
209
+
210
+ * Auto Completion
211
+ * [Autoimport](docs/autoimport.md)
212
+ * Code Linting
213
+ * Code actions
214
+ * Signature Help
215
+ * Go to definition
216
+ * Hover
217
+ * Find References
218
+ * Document Symbols
219
+ * Document Formatting
220
+ * Code folding
221
+ * Multiple workspaces
222
+
223
+ ## Development
224
+
225
+ Dev install
226
+
227
+ ```
228
+ # (optional) create conda env
229
+ conda create --name python-lsp-server python=3.11 -y
230
+ conda activate python-lsp-server
231
+
232
+ pip install -e ".[all,websockets,test]"
233
+ ```
234
+
235
+ Run server with ws
236
+
237
+ ```
238
+ pylsp --ws -v # Info level logging
239
+ pylsp --ws -vv # Debug level logging
240
+ ```
241
+
242
+ To run the test suite:
243
+
244
+ ```sh
245
+ # requires: pip install ".[test]" (see above)
246
+ pytest
247
+ ```
248
+
249
+ Running ruff as a linter and code formatter on the repo:
250
+ ```sh
251
+ ruff check . # linter
252
+ ruff check --fix . # fix all auto-fixable lint issues
253
+ ruff format . # format the document
254
+ ```
255
+
256
+ After adding configuration options to `schema.json`, refresh the `CONFIGURATION.md` file with
257
+
258
+ ```
259
+ python scripts/jsonschema2md.py pylsp/config/schema.json CONFIGURATION.md
260
+ ```
261
+
262
+ ## License
263
+
264
+ This project is made available under the MIT License.
@@ -0,0 +1,46 @@
1
+ deepnote_python_lsp_server-1.13.1rc2.dist-info/licenses/LICENSE,sha256=rsArR45X85WuRYArKqcPz5m7o-q_TNcAwGXNYqfZKhs,1147
2
+ pylsp/__init__.py,sha256=pp21AWL0whEQYBt-9_tsAH1Mgb985QScnzSgqx3poTI,762
3
+ pylsp/__main__.py,sha256=w8nAz5jnDSlrSbNyuukEnkSpcDpei0LVmR1uyPgUyNM,3889
4
+ pylsp/_utils.py,sha256=nXD3FCUDXnlTgoI2-4ob-AcUi1CseovGTEkvLfeyu7o,12547
5
+ pylsp/_version.py,sha256=HBvM3EjpD4Kogt8Xn9wt-kxfd_8KX2vEkROr3m-mA-M,26
6
+ pylsp/hookspecs.py,sha256=3RU32ram1__kLdoWfRE7m2XLlXj22KAIH0kndggoGbo,2785
7
+ pylsp/lsp.py,sha256=UNoXmPraDwcgD7KsWjuWqTbi1NBBN7fOpDBL_vkn__A,2050
8
+ pylsp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ pylsp/python_lsp.py,sha256=UDd3pmcJnWz-sCyo6-EM0_Rf8MsGbDE1IZu-61Z3dFc,37381
10
+ pylsp/text_edit.py,sha256=0CKXPieuvOenmerfeb2Rgt-YSuwqORSkracSv8dxnlg,2768
11
+ pylsp/uris.py,sha256=nFpHptnOyQ4xt_xfCep7xMmmzaWGdX2Dhwb5Z92cNt8,3824
12
+ pylsp/workspace.py,sha256=TuGmiB7SLBr5xME1iXZUyh_d-_2KtlwKO-CbuzbcFmY,24381
13
+ pylsp/config/__init__.py,sha256=bDWxRjmELPCVGy243_0kNrG7PttyZsv_eZ9JTKQrU1E,105
14
+ pylsp/config/config.py,sha256=mWpuklH2CMH0LLXB5SgXtC73qs6UAanBBvybrkxBR1M,6977
15
+ pylsp/config/flake8_conf.py,sha256=PvNkDnckn5lTr5q-LieIAKAEXoXDnzeGdApFNdMfp4k,2370
16
+ pylsp/config/pycodestyle_conf.py,sha256=QeTq5yEXIMidIPs2pjuE450X3VudUu9F3DTHHCFaASk,1268
17
+ pylsp/config/source.py,sha256=PiKrKgsRmROZp-qRbzpGXNkKSlNF-Y-d94IygK4cSCg,2753
18
+ pylsp/plugins/__init__.py,sha256=bDWxRjmELPCVGy243_0kNrG7PttyZsv_eZ9JTKQrU1E,105
19
+ pylsp/plugins/_resolvers.py,sha256=GfY3FwtAnIJhrTMAofe8SRpv6E1ptkQ07gue-hVpv1s,4386
20
+ pylsp/plugins/_rope_task_handle.py,sha256=q9kP7hhP8FPUX93shruT4AATU2f9Frty2UTMtnDDfhI,2883
21
+ pylsp/plugins/autopep8_format.py,sha256=iLJ9FYbH_7NcyyeKpXVNAKLCzG5-FnWsgE13iidb2IE,3185
22
+ pylsp/plugins/definition.py,sha256=goGhvDINYGawrxagZKxndwuo8HWDyLwpKKMn7tV73Ko,2658
23
+ pylsp/plugins/flake8_lint.py,sha256=Q_woUfcFU8V-nz04cBT1EhJvCn1zAhoHXPR-LBJl9aE,8317
24
+ pylsp/plugins/folding.py,sha256=tMudxoyr5gp2HJ6P06tJGkSOVCBbI2CgBpVELkm1o-E,7035
25
+ pylsp/plugins/highlight.py,sha256=VzBDNJWrbRexiCYA5a6-RWRuipaxC-BLRhmT4k-ryu4,1100
26
+ pylsp/plugins/hover.py,sha256=pe_0jeTh3hxzjYOUQ4jozvlfCL3gRHmy-cApCOEk5HQ,1750
27
+ pylsp/plugins/jedi_completion.py,sha256=ZzYo4dTfwWBUYvuXLM8KcLECbYUnB5nWI_TVNtfmTF0,11563
28
+ pylsp/plugins/jedi_rename.py,sha256=JKIb7lcLHkIgJ2k83SZmgDr0fTxMG_jpEhfS_gfXTuI,1908
29
+ pylsp/plugins/mccabe_lint.py,sha256=AqiojhZAqK3eXW6LXFXZqg3uCawept5Qod7CoaX9omM,1826
30
+ pylsp/plugins/preload_imports.py,sha256=zCy5D9-sbcr-B9pn3RMbasnLy7RZcQYGTajA7FR7XTk,1428
31
+ pylsp/plugins/pycodestyle_lint.py,sha256=1nECd4jHeuS1cwIdgIjDzYVczj4xDGbWqDCaiN_ABa4,4011
32
+ pylsp/plugins/pydocstyle_lint.py,sha256=EDUaKhjibqs1Kr5L8ECoDm6VCNbnuP8FzhjBJo1iQkA,4172
33
+ pylsp/plugins/pyflakes_lint.py,sha256=n0KTtmKdZindHqHFhNPEgqCPrFKDD2TI0LLUbJvDiX0,3137
34
+ pylsp/plugins/pylint_lint.py,sha256=QcTKdoPRZgc8tnV7D7JqLAA-bldD9ucWwdszSzXGulw,12372
35
+ pylsp/plugins/references.py,sha256=sXCBw9qr-02yIbYO40YSAfaW_ENVY7X7s07xNeezlmg,1036
36
+ pylsp/plugins/rope_autoimport.py,sha256=Pm9kxpVo9u4oeeCLIsXbq6Uo-V8qcIyOuIPM9THrR5Y,13367
37
+ pylsp/plugins/rope_completion.py,sha256=hfNEHEPuyKy3vl1ZV8JByYIBgM0WDvnW4_MTMXNh2ts,5911
38
+ pylsp/plugins/signature.py,sha256=j_A_5uka816uyRAZW-Go1khHTY43MT0j-10d58NHf8s,2592
39
+ pylsp/plugins/symbols.py,sha256=bnF_kYTsdEFxpULGYb89_RoqAhBIcnHYd5VxW6aXG1U,8073
40
+ pylsp/plugins/type_definition.py,sha256=dNzowNlJbDh2CkZTAvM34TGSAB0AL6yA6uzE0g-qaG0,1080
41
+ pylsp/plugins/yapf_format.py,sha256=Ds5WXxeXQaQqoiXwXmKe8sXzlLrsjQPGzyBk7HW8B5k,6785
42
+ deepnote_python_lsp_server-1.13.1rc2.dist-info/METADATA,sha256=yxW4m7mIw8cZbSvR9fs4UZwcYIQHHQobaQ8ZudpA0WQ,10976
43
+ deepnote_python_lsp_server-1.13.1rc2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
44
+ deepnote_python_lsp_server-1.13.1rc2.dist-info/entry_points.txt,sha256=dE_inbf61lmFlHVtIwXzQzsYRxzxzSrkimjNh2GVK-g,913
45
+ deepnote_python_lsp_server-1.13.1rc2.dist-info/top_level.txt,sha256=LamqoHzmagL8tkMqWx8FqE2ByHDcRKZwh7OJEyvru14,6
46
+ deepnote_python_lsp_server-1.13.1rc2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,25 @@
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
+ jedi_type_definition = pylsp.plugins.type_definition
17
+ mccabe = pylsp.plugins.mccabe_lint
18
+ preload = pylsp.plugins.preload_imports
19
+ pycodestyle = pylsp.plugins.pycodestyle_lint
20
+ pydocstyle = pylsp.plugins.pydocstyle_lint
21
+ pyflakes = pylsp.plugins.pyflakes_lint
22
+ pylint = pylsp.plugins.pylint_lint
23
+ rope_autoimport = pylsp.plugins.rope_autoimport
24
+ rope_completion = pylsp.plugins.rope_completion
25
+ 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 {} - %(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, 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()