🐍 Copy Python Qualified Path
A Visual Studio Code extension that adds a right-click menu option to copy the fully-qualified Python path of a class or method — just like PyCharm.
🔗 From this:
# File: src/utils/mymodule.py
class MyClass:
def get_numbers(self):
pass
📋 To this copied string:
src.utils.mymodule.MyClass.get_numbers
✨ Features
- ✅ Adds
Copy Qualified Path to the right-click context menu.
- ✅ Automatically detects the Python module path based on your project structure.
- ✅ Works with both classes and functions.
- ✅ Detects the enclosing class of a method automatically.
🛠️ Installation
From Marketplace
Coming soon: Marketplace Link
Local .vsix file
code --install-extension copy-python-qualified-path-0.0.1.vsix
🚀 Usage
- Open any
.py file in your project.
- Right-click on a class or method name.
- Select
Copy Qualified Path .
- The path will be copied in the format:
your.module.path.ClassName.method_name
⚙️ How It Works
- Determines the Python module path by resolving the file's location relative to the project root (
.git , .vscode , pyproject.toml , etc.).
- Parses the current line to extract class or method definitions.
- If only a method is selected, attempts to find the enclosing class upward in the file.
🧪 Example Output
File Path |
Selection |
Copied Path |
project/api/user/views.py |
UserView.get |
project.api.user.views.UserView.get |
core/database/init.py |
setup_db() |
core.database.init.setup_db |
🙋 FAQ
Q: Does it support nested classes?
A: Currently, it supports single-level classes. Nested class support is coming soon.
Q: How is the module root detected?
A: It walks up the directory tree looking for .git , .vscode , or pyproject.toml .
💡 Future Ideas
- no future ideas, its enough for now
🧑💻 Author
Made with ❤️ by @kdrkrgz
🪪 License
MIT License
| |