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

Python CodeLens

Prasad G K

|
4,988 installs
| (5) | Free
View reference counts for Python symbols with inline CodeLens and a dedicated Symbol Overview panel. Navigate code easily with alphabetically sorted classes and methods.
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. It provides both inline CodeLens reference counts and a dedicated Symbol Overview panel for easy navigation and analysis of your Python code.

Features

  • Inline Reference Counts: Displays the number of references for classes, methods, and functions directly above each symbol in the editor.
  • Symbol Overview Panel: A dedicated Activity Bar view that lists all classes and methods in the current file with their reference counts.
    • Alphabetically sorted symbol list
    • Click any symbol to navigate directly to its definition
    • Reference counts displayed for each symbol
    • Automatically updates when switching files or editing code
  • Navigation: Click on reference counts (inline or in panel) to view and navigate to referenced locations.
  • Auto-Refresh: Automatically refreshes when Python files are modified, created, or deleted.
  • Configuration Watcher: Watches for changes in Python interpreter configuration and refreshes 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

Inline CodeLens

  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.

Symbol Overview Panel

  1. Click the Python CodeLens icon in the Activity Bar (left sidebar).
  2. The Symbol Overview panel will display all classes and methods from the active Python file.
  3. Click any symbol in the panel to navigate to its definition in the editor.
  4. Reference counts are shown next to each symbol.
  5. Use the refresh button in the panel title bar to manually refresh the symbol list.

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.1.0

New Feature: Symbol Overview Panel

  • Added a dedicated Activity Bar view showing all classes and methods in the current Python file
  • Alphabetically sorted symbol list for easy navigation
  • Reference counts displayed next to each symbol
  • Click any symbol to jump directly to its definition in the editor
  • Automatic updates when switching files or editing code
  • Manual refresh button in panel title bar
  • Both sections (Classes and Methods) expanded by default for quick access

Improvements:

  • Refactored symbol detection logic into a shared service for better performance
  • Reference count cache now shared between inline CodeLens and Symbol Overview panel
  • Enhanced initialization for better startup behavior when VSCode opens with Python files
  • Debounced refresh mechanism (500ms) to optimize performance during rapid code changes

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.

1.0.1

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

1.0.0

  • Initial release of Python CodeLens.

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
© 2026 Microsoft