A Visual Studio Code Extension to show the inferred Method Resolution Order (MRO) list of a Python class/object via Hover or CodeLens by leveraging the functionality of the Python MRO Language Server.
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 extension takes the advantage of Hover and CodeLens to conveniently show the inferred MRO list in VS Code. Moreover, the extension listens to the documentation changes so can take the unsaved changes into account during the MRO inference.
Ultimately, the extension aims to provide useful MRO information when user hovers over an entity in the editor. For example, the extension aims to show the MRO list when hovering over a class instance, or to show the order list of the parent classes which actually implements the method under hover.
Currently, this extension is able to show the MRO list when user hovers over the declared class name in its declaration section.
Ultimately, the extension aims to provide the MRO list for each user-declared class by a CodeLens at the start of the declaration section. The user can view the MRO list in a side panel by clicking the CodeLens, which works like the GitLens.
Currently, the MRO list will show in a pop-up message window at the right-bottom corner of the editor, but this will be upgraded to the mentioned side panel in a next release very soon.
Please use the following command to install the Python MRO Language Server
via Pip in your machine to properly use this extension:
python3 -m pip install python-mro-language-server
This extension will automatically launch when a Python file is open. It will also automatically launch a Python MRO Language Server during its launch process.
Currently there is no setting option available to the user. But they will become available in the next releases.
Please refer to the CHANGELOG.
The following list includes the features to add into the Python MRO extension in the next releases.
- Add Support to Language Server's 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 logging to the whole scope of the project and save the last logs in file
Any contribution is welcomed!