2 Star 0 Fork 0

mirrors_sourcegraph/python-langserver

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
Loading...
README
MIT

Python language server


NOTE: This project is no longer being maintained or in active development. See the Sourcegraph fork of Microsoft's Python language server.


Build Status

This is a language server for Python that adheres to the Language Server Protocol (LSP). It uses Jedi to perform source code analysis. Python versions 2.x and 3.x are supported.

Automatic Dependency Installation

Configuring pip

python-langserver uses pip to fetch dependencies. To configure the behavior of pip, you can supply the pipArgs initalizationOption field inside the initalize request parameters. pipArgs specifies a list of arguments to add to the invocation of pip, for example:

InitializeParams {
	//...
	"initializationOptions": {
        "pipArgs": [
            "--index-url=https://python.example.com",
            "--extra-index-url=https://pypi.python.org/simple"
        ]
        // ...
    }
}

This will tell pip to use https://python.example.com as its base package index and https://pypi.python.org/simple as an extra package index, as described in the pip documentation.

Note, when using this language server with Sourcegraph - you can set the initializationOptions in your site configuration:


{
    // ...
    "langservers": [
        {
            "language": "python",
            "initializationOptions": {
                "pipArgs": [
                    "--index-url=https://python.example.com",
                    "--extra-index-url=https://pypi.python.org/simple"
                ]
            }
        }
    ]
    // ...
}

Inference of Package Names

The language server will not run setup.py or pip install. When it encounters an import, it tries to infer the package name and run pip download. (This also avoids running the downloaded package's setup.py.) This is expected to work as long as the name of the package on PyPI (or your private package index) is the same as the name that's imported in the source code.

Development

Getting started

You'll need Python version 3.6 or greater or pyenv installed. You will also need pipenv installed:

  1. pipenv install
  2. pipenv run python python-langserver.py --mode=tcp --addr=2087

To try it in Visual Studio Code, install the vscode-client extension and then open up a .py file.

Tests

Run make test.

The tests require pytest. Note that some tests may fail if you're using virtualenv instead of the system Python.

Copyright (c) 2016 Sourcegraph Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Language server which talks LSP via JSONRPC for Python. 展开 收起
README
MIT
取消

发行版

暂无发行版

近期动态

4年多前创建了仓库
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_sourcegraph/python-langserver.git
git@gitee.com:mirrors_sourcegraph/python-langserver.git
mirrors_sourcegraph
python-langserver
python-langserver
master

搜索帮助