-
Notifications
You must be signed in to change notification settings - Fork 74
VS Code Usage
Sourcery scans the currently open Python file. If it finds improvements in your code it returns them as a list of Info-level problems. You can see these directly in the code editor as underlined sections.
Hovering over a suggestion with the mouse will show you the suggested diff.
The extension can also show you inline code metrics, giving you an instant view of your code quality. You can hover over a function's definition to get an instant view of its code quality, and functions with very low quality will show up as warnings in the Problems pane.
See the Sourcery Tutorial for more detailed info.
The refactorings appear in the Problems window (Ctrl+Shift+M). You can navigate between problems using F8.
Refactorings are applied via a Quick Fix:
- Press
Ctrl+.
on the suggested refactoring and it will bring up the quick fix menu with an option to apply it. - Hover the mouse over the refactoring and a lightbulb will appear. Click the lightbulb and apply the refactoring.
- Hovering over the refactoring in the Problems window will also show this lightbulb.
Please see skipping refactorings on how to do this. The VSCode extension also provides code actions to add these comments automatically.
Just select Sourcery - skip suggested refactorings
from the quick fix menu.
In VS Code right click on a folder in the Explorer and select "Scan with Sourcery". Sourcery will then analyse all files in that folder and suggest refactorings. Results will appear in the Problems window.
Scanning multiple files with Sourcery requires a Sourcery Pro subscription.
If you have the Sourcery GitHub Bot installed you can request to refactor a whole repo from the Sourcery website dashboard.
Please visit our newer docs at https://docs.sourcery.ai