-
Notifications
You must be signed in to change notification settings - Fork 72
PyCharm Usage
Sourcery scans the currently open Python file. If it finds improvements in your code it returns them as a list of refactorings. You can see these in the editor as highlighted sections of code.
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 highlighted warnings.
See the Sourcery Tutorial for more detailed info.
The refactorings appear in the Sourcery tool window (which appears at the bottom of the screen). You can click on each refactoring to scroll to it. To see a diff of the suggested changes, click on the arrow next to it in the tool window to expand it.
There are 3 options:
- Press
Alt+Enter
on the suggested refactoring and apply the refactoring - Hover the mouse over the refactoring and a lightbulb will appear. Click the lightbulb and apply the refactoring.
- Right click on the suggested refactoring in the Sourcery window and select the
Refactor function
option
You can configure Sourcery to ignore certain files or folders in your project. Please see the Sourcery configuration section for details.
Please see skipping refactorings on how to do this. The PyCharm plugin has shortcuts to adds these comments automatically.
In PyCharm right click on a folder and select "Inspect Code...". Then choose Sourcery from the Inspection Profile dropdown and run the inspection. Results will appear in the "Inspection Results" 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