Skip to content

VS Code Extension to show the MRO (Method Resolution Order) of classes.

License

Notifications You must be signed in to change notification settings

mosckital/vscode_python_mro

Repository files navigation

VS Code Extension: Python MRO

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.

Continuous Integration Status GitHub license

Features

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.

Showing the MRO list via Hover

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.

Showing the MRO list via CodeLens

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.

Requirements - Python MRO Language Server

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

Usage

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.

Extension Settings

Currently there is no setting option available to the user. But they will become available in the next releases.

Release Notes

Please refer to the CHANGELOG.

Incoming Features

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.
  • Project Reliability
    • increase the readability of the documentations
    • add logging to the whole scope of the project and save the last logs in file

Contribution

Any contribution is welcomed!

About

VS Code Extension to show the MRO (Method Resolution Order) of classes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published