Google Python Style Guide Rules¶
Sourcery ships with a set of optional rules that, combined, implement a portion of the Google Python Style Guide.
It also defines several subsets of optional rules that you can switch on and off individually:
- gpsg-import
- gpsg-standard-import-alias
- gpsg-lambda
- gpsg-type-annotations
- gpsg-docstrings
- gpsg-naming
- gpsg-naming-pep8
The rules can be found in the sourcery-rules public repo
Usage¶
One-off Review in the CLI¶
To review your project with all these rules in the command line, you can run:
sourcery review --enable gpsg .
You can also pick only a subset of these rules. For example, to review your project only with the import rules, you can run:
sourcery review --enable gpsg-import .
Add the Google Python Style Guide to 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.
To configure the whole Google Python Style Guide:
rule_settings:
enable:
- default
- gpsg
To configure only the import rules from the Google Python Style Guide:
rule_settings:
enable:
- default
- gpsg-import
You can also copy any of the rules or the Complete Rule Set into your project's .sourcery.yaml
. file. This way, you can also tweak the rules. For example, you can configure them to be applied only in specific directories.
See Also