Generate architecture rules for Python projects.
Project description
Sourcery Rules Generator
This is an experimental project. It might become a part of the Sourcery CLI.
Sourcery Rules Generator creates architecture rules for your project.
The generated rules can be used by Sourcery to review your project's architecture.
Currently, the project can create dependency rules.
Usage
You can create Sourcery rules based on a template with the command:
sourcery-rules <TEMPLATE-NAME> create
Supported templates:
- dependencies
- naming (coming soon)
For example:
sourcery-rules dependencies create
Create Dependencies Rules
With the dependencies template, you can create rules to check the dependencies:
- between the packages of your application
- to external packages.
Let's say your project has an architecture like this:
You can create rules to ensure:
- no other package imports
api
- only
api
importscore
- only
db
importSQLAlchemy
- etc.
Run the command:
sourcery-rules dependencies create
You'll be prompted to provide:
- a package name
- the packages that are allowed to import the package above
The 2nd parameter is optional.
E.g. it makes sense to say that no other package should import the api
or cli
package of your project.
=>
2 rules will be generated:
- 1 for
import
statements - 1 for
from ... import
statements
Using the Generated Rules
The generated rules can be used by Sourcery to review your project.
If you copy the generated rules into your project's .sourcery.yaml
, Sourcery will use them automatically.
All the generated rules have the tag architecture
. Once you've copied them to your .sourcery.yaml
, you can run them with:
sourcery review --enable architecture .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sourcery_rules_generator-0.3.0.tar.gz
.
File metadata
- Download URL: sourcery_rules_generator-0.3.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.19.0-26-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c70f14ca7825a9b8f1fa4a30500e65a482839699cae8674ff257adcb885ac6b6 |
|
MD5 | a6c97d9a5245e214ba21bf655282043e |
|
BLAKE2b-256 | bc0ff650de2038ba1a5d7ac9ccae4c508271eb169834274be1b9a8327b4fb3dc |
File details
Details for the file sourcery_rules_generator-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: sourcery_rules_generator-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.19.0-26-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d18a9aa8604890108cae9e0dd4987c2e54897bed6645919b43aec2d3302fd9b6 |
|
MD5 | 2ab8262b8f5116561aa211dfc9195b62 |
|
BLAKE2b-256 | f5b1e1801a83931102e45aa84de829d02057182bcf021ecb7fc93630620b7085 |