Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>Python CodeLensNew to Visual Studio Code? Get it now.
Python CodeLens

Python CodeLens

Prasad G K

|
1,418 installs
| (3) | Free
Show reference details for python symbols like Classes, Methods and Functions.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Python CodeLens

Python CodeLens is a Visual Studio Code extension that displays reference counts for Python symbols such as Classes, Methods, and Functions. This extension helps developers quickly identify how many times and where a particular symbol is referenced within the workspace.

Features

  • Reference Counts: Displays the number of references for classes, methods, and functions directly above the symbol.
  • Navigation: Click on the reference count to view and navigate to the referenced locations.
  • Auto-Refresh: Automatically refreshes the reference counts when Python files are modified, created, or deleted.
  • Configuration Watcher: Watches for changes in the Python interpreter configuration and refreshes the reference counts accordingly.

[!WARNING] Please note that enabling the filterImports configuration may impact performance, as it iterates through all references and applies a regex to filter out import references. For large projects, we recommend keeping this option disabled.

Configurations

Codelense supports the following configurations:

{
  "codeLens.enableCodeLens": true,
  "codeLens.filterImports": false,
  "codeLens.filterDefinitions": true
}
  • enableCodeLens: Controls the enablement of the entire CodeLens feature.
  • filterImports: Provides a configuration option to exclude import statements from the Reference Count and Peek Preview window.
  • filterDefinitions: Offers a configuration setting to exclude symbol definitions from the Reference Count and Peek Preview window.

Requirements

  • Python Extension: This extension depends on the Python Extension by Microsoft. Ensure that you have this extension installed and configured before using Python CodeLens.

Installation

  1. Install the Python Extension by Microsoft.
  2. Install the Python CodeLens extension from the Visual Studio Code Marketplace.
  3. Reload or restart Visual Studio Code to activate the extension.

Usage

  1. Open a Python file in Visual Studio Code.
  2. The reference counts for classes, methods, and functions will be displayed above the respective symbols.
  3. Click on the reference count to view and navigate to the referenced locations.

Known Issues

  • Ensure that the Python environment or interpreter is selected to avoid errors.
  • Implement an effective logging mechanism for better error handling and debugging.

Release Notes

1.0.0

  • Initial release of Python CodeLens.

1.0.1

  • Bug fixes and performance enhancements implemented by introducing a caching mechanism.

1.0.2

  • Introduced configurations to manage reference count and Peek Preview visibility for symbol definitions and import statements. Refer to the feature section for more details on the new configuration options.

Contributing

Contributions are welcome! We are working on setting up the public repository where people can open an issue or submit pull requests.

License

This project is licensed under the MIT License and details will be updated soon.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft