A simple Python language server to provide MRO (Method Resolution Order) inference via Hover and CodeLens.
Project description
Python MRO Language Server
A simple Python language server to provide MRO (Method Resolution Order) inference.
MRO is the order in which Python looks for a method in a hierarchy of classes. Python uses C3 Linearisation (wiki page) as the underlying algorithm.
This project conforms to Microsoft's Language Server Protocol but only support Hover and CodeLens requests. Python 3.6+ are supported.
Installation
The Python MRO language server can be easily installed by:
pip install python-mro-language-server
The language server uses jedi
for static syntax analysis and python-jsonrpc-server
for the JsonRPC communications. These two packages and their dependencies, ujson
and parso
, will be installed by the about command as well.
Usage
The Python MRO language server can be launched by the following command:
python -m mrols.server [port]
Where port
is 3000 by default if not specified.
Language Server Features
The main purpose of this language server is to infer and return the MRO of a target in request via static syntax analysis of the provided source codes.
By static syntax analysis, there is a minimum level of security risk since the source codes will not be run. This is at the expense that the inference may be incomplete in some situations, like when using a dynamically declared type or having no information about the external library. However, the user can expect that the inference should work in a large part of the common cases.
The necessary static syntax analysis is achieved by using both the jedi
analysis library and the Python built-in library ast
(stands for Abstract Syntax Trees). The jedi
library is in primary use and the ast
library provides additional supports.
Hover functionality
The Python MRO Language Server implements the Hover Request of the Language Server Protocol. The user can fetch the MRO list of a class or its instance by hovering over the class name (implemented) or instance name (to implement very soon).
CodeLens functionality
The Python MRO Language Server implements the Code Lens Request and the Code Lens Resolve Request as well. A code lens will appear at the first line of every class declaration. The user can get the MRO list of the declared class by clicking the code lens.
Relation to the Python MRO extension for VS Code
This language server is the backend server used in the Python MRO extension for VS Code.
It is very welcomed that this language server can be used in any other extensions to any editor that supports the Language Server Protocol.
Incoming Features
The following list includes the features to add into the Python MRO Language Server in the next releases.
- New Features:
- Hover:
- add support to show MRO list when hovering over a class instance
- add support to show the which class in the MRO list will provide the actual implementation when hovering over a method of a class instance (lower priority, scheduled after finishing the other features)
- CodeLens:
- change the way to show MRO list when clicking a code lens from showing in a pop-up message window to showing in a side panel like what GitLens does.
- Hover:
- Project Reliability
- increase the readability of the documentations
- add coverage check and show the result as a badge in README
- add pylint check and show the score as a badge in README
- add logging to the whole scope of the project and save the last logs in file
Contribution
Any contribution is welcomed!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python-mro-language-server-0.0.1-1.tar.gz
.
File metadata
- Download URL: python-mro-language-server-0.0.1-1.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22afdb49f11f8e5da679b978379fc1fffe4b17475729be072da19a5d6c83efa6 |
|
MD5 | e9f6a0e73b971fdb3c52097bdac3daef |
|
BLAKE2b-256 | 98aaad7322e96debbcb358c460ba909f886a3aaddfc0c2f0ec953337e6a49a5d |
File details
Details for the file python_mro_language_server-0.0.1-1-py3-none-any.whl
.
File metadata
- Download URL: python_mro_language_server-0.0.1-1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71af9634c20a3cfe93f92a1cf19f9ca154252b99a540f89b8f5b90c22f5c908a |
|
MD5 | c8123d7759a07d208d57319adefc8e67 |
|
BLAKE2b-256 | 35a9aa39f6dea75c6b5c48432d98a1afbe0112a7ef1e1b4ebb96d76b7ab06a33 |