Skip to main content

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

screenshot sourcery-rules 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:

dependencies overview

You can create rules to ensure:

  • no other package imports api
  • only api imports core
  • only db import SQLAlchemy
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sourcery_rules_generator-0.2.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

sourcery_rules_generator-0.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file sourcery_rules_generator-0.2.0.tar.gz.

File metadata

  • Download URL: sourcery_rules_generator-0.2.0.tar.gz
  • Upload date:
  • Size: 4.4 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

Hashes for sourcery_rules_generator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 60b4e9ae959a73565bcf4e565867aed632155f8890f380817c0a4ec2ee5812f3
MD5 87d4d607d400815323515c3a1f0e0408
BLAKE2b-256 974acf80a0f504b5a4a19075cc6f44fffba3ce510a7379f3016ebab66c1028df

See more details on using hashes here.

File details

Details for the file sourcery_rules_generator-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sourcery_rules_generator-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d24bcc8d281130efda35b24ab387d903582dc1b611f1527aeff89e2f3fe2e451
MD5 14ec27ac190d45092818000c56cadb96
BLAKE2b-256 d270c4b6e67dfd6f1605d8282e410b72f3d8324eb724df10c4cd99a09b15c56e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page