Skip to content

VS Code Usage

Brendan Maginnis edited this page Jun 27, 2020 · 10 revisions

How does it work?

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.

How do I see all the refactorings?

The refactorings appear in the Problems window (Ctrl+Shift+M). You can navigate between problems using F8.

How do I apply a refactoring?

Refactorings are applied via a Quick Fix:

  1. Press Ctrl+. on the suggested refactoring and it will bring up the quick fix menu with an option to apply it.
  2. Hover the mouse over the refactoring and a lightbulb will appear. Click the lightbulb and apply the refactoring.
  3. Hovering over the refactoring in the Problems window will also show this lightbulb.

How do I disable Sourcery on a function?

Please see disable refactorings on how to do this. The VSCode extension has shortcuts to adds these comments automatically.

How do I refactor my whole project?

The Sourcery plugins can only currently refactor one file at a time.

If you have the Sourcery GitHub Bot installed you can request to refactor a whole repo from the sourcery website dashboard.

Clone this wiki locally