Skip to content

Optional Rules

Sourcery ships with various optional rules. These also reflect general and Python best practices, but are more opinionated than the default rules Try out the optional rules and pick the ones that are relevant for your project.

All optional rules can be found in the public sourcery-rules repo

Try Out Optional Rules in the Sourcery CLI

If you want to analyze your code with an optional rule set, use the --enable option of the Sourcery CLI:

sourcery review --enable gpsg .

Or with a smaller optional rule set:

sourcery review --enable gpsg-import .

Enable Optional Rules in Your Sourcery Config

You can add the whole GPSG rule set or a subset of it to your project's .sourcery.yaml config file. This way, Sourcery will use these rules anytime it reviews your project in the CLI or in an IDE.

GPSG in VSCode

To configure the whole Google Python Style Guide:

    - default
    - gpsg

To configure only the import rules from the Google Python Style Guide:

    - default
    - gpsg-import