A tool to enforce architectural patterns in python projects
Project description
Deply
Deply is a standalone Python tool for enforcing architectural patterns and dependencies in large python projects. By analyzing code structure and dependencies, this tool ensures that architectural rules are followed, promoting cleaner, more maintainable, and modular codebases.
Inspired by https://github.com/qossmic/deptrac
Features
- Layer-Based Analysis: Define project layers and restrict their dependencies to enforce modularity.
- Dynamic Layer Configuration: Easily configure collectors for each layer using file patterns and class inheritance.
- Cross-Layer Dependency Rules (TODO): Specify rules to disallow certain layers from accessing others.
- Extensible and Configurable: Customize layers and rules for any python project setup.
Installation
To install Deply, use pip
:
pip install deply
Configuration
Before running the tool, create a configuration file (config.yaml
or similar) that specifies the rules and target
files to enforce.
Example Configuration (config.example.yaml
)
layers:
- name: models
collectors:
- type: class_inherits
base_class: "django.db.models.Model"
- name: services
collectors:
- type: file_regex
regex: "^.*/providers.py$"
- name: views
collectors:
- type: file_regex
regex: ".*/views_api.py"
ruleset:
views:
disallow:
- models # Disallows direct access to models in views
Usage
Run the tool from the command line by specifying the project root directory and configuration file:
python deply.py --project_root='/path/to/your_project' --config=config.example.yaml
Arguments
--project_root
: The path to the root of the project where apps are located.--config
: Path to the configuration file that defines the rules and target files.
Sample Output
If violations are found, the tool will output a summary of architectural violations grouped by app, along with details of each violation, such as the file, line number, and violation message.
/path/to/your_project/your_project/app1/views_api.py:74 - Layer 'views' is not allowed to depend on layer 'models'
Running Tests
To test the tool, use unittest
:
python -m unittest discover tests
License
See the LICENSE file for details.
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
Built Distribution
File details
Details for the file deply-0.1.1.tar.gz
.
File metadata
- Download URL: deply-0.1.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8ccd582226591634db10a1e708b3b305713649afb9d0ff0480bdd3f34f48300 |
|
MD5 | 4f9a5690f34a7ddcfa318f8836678ce9 |
|
BLAKE2b-256 | 54bec70c44868c290d3ce84740cece0ee2239abf6dacae5d9a6ab5c9207fe8e6 |
File details
Details for the file deply-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: deply-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af9a552adc1c8984b11783e7a7d9db8af645ac748fb0967294ab6a694afc3d52 |
|
MD5 | b82eb1ffaa7bb1d1b32c703a094e10a4 |
|
BLAKE2b-256 | 42242d0f5d10a335a1adf426e3699fef4637302c726e8c1744340d75516db4af |