Deply
Deply is a static code analysis tool for Python that helps you communicate, visualize and enforce architectural decisions in your projects. You can freely define your architectural layers over classes and which rules should apply to them.
For example, you can use Deply to ensure that modules/packages in your project are truly independent of each other to make them easier to reuse.
Deply can be used in a CI pipeline to make sure a pull request does not violate any of the architectural rules you defined. With the optional Mermaid formatter you can visualize your layers, rules and violations.
Documentation
You can find the documentation in the /doc directory or visit the doc page: https://vashkatsi.github.io/deply
Getting Started
You can install Deply via pip:
pip install deply
Once you have installed Deply, you will need to create a configuration file, where you define your layers and communication ruleset. This configuration file is written in YAML and, by default, is stored with the name deply.yaml in your project's root directory.
When you have this file, you can analyse your code by running the analyze command:
deply analyze
# which is equivalent to
deply analyze --config=deply.yaml
In order to run Deply you need at least Python 3.8. Supported and tested versions: Python 3.8 to 3.14.
Example Configuration
Here's a simple example of a deply.yaml configuration file:
deply:
paths:
- /path/to/your/project
exclude_files:
- ".*\\.venv/.*"
layers:
- name: models
collectors:
- type: class_inherits
base_class: "django.db.models.Model"
- name: views
collectors:
- type: file_regex
regex: ".*/views_api.py"
- name: services
collectors:
- type: class_name_regex
class_name_regex: ".*Service$"
ruleset:
views:
disallow_layer_dependencies:
- models
services:
disallow_external_imports:
- django
- requests
Code elements may belong to multiple layers. Deply checks every unique source and target layer pair, so layer and collector order does not change dependency or external-import results.
Command-Line Usage
# Basic usage
deply analyze
# With a specific config file
deply analyze --config=custom_config.yaml
# Validate configuration only
deply validate --config=custom_config.yaml
# Generate a Mermaid diagram
deply analyze --mermaid
# Get help
deply --help
deply analyze validates the configuration before scanning project files and
exits with status 1 when the configuration is invalid or analysis is
incomplete because files cannot be read or parsed, no Python files are found,
or no code elements map to configured layers.
Every completed analysis report includes completeness metrics for discovered, excluded, parsed, mapped, and unmapped files; mapped and overlapping elements; and detected dependencies. Incomplete analysis prints the available metrics to standard error before exiting.
Agent Skill
Deply v1.1.2 includes a portable Agent Skill at skills/deply-config/ for Codex, Claude Code, and other Agent Skills-compatible assistants. It helps an assistant inspect a Python project, generate deply.yaml using light, medium, or strict guidance, validate it with deply validate, run analysis, and add Makefile/CI/docs integration. These profiles belong to the Agent Skill; they are not built-in Deply CLI presets.
Use it with:
Use $deply-config to create and validate a Deply architecture config for this Python project.
See Agent Skill for installation instructions.
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, class inheritance, and logical conditions.
- Cross-Layer Dependency Rules: Specify rules to disallow certain layers from accessing others. Internal dependency inference currently matches unqualified names globally, so imported aliases may be missed and equal names may overmatch.
- External Import Restrictions: Prevent selected layers from importing framework, persistence, or SDK package roots through absolute imports. Relative imports are ignored.
- Extensible and Configurable: Customize layers with built-in or custom collectors and supported rules.
- Mermaid Diagrams: Visualize your architecture and dependencies with Mermaid diagrams.
- Error Suppression: Suppress specific rule violations with inline comments.
- Config Validation: Validate
deply.yamlexplicitly or automatically before analysis. - SARIF Reports: Export findings for GitHub Code Scanning with
deply analyze --report-format=sarif --output=deply.sarif. See the CLI guide for upload instructions and limitations. - Architecture Recipes: Copy and adapt documented configurations for 21 architecture and application patterns; they are not built-in presets.
Error Suppression
Deply provides options to suppress rule violations using comments in your code:
# Line-level suppression
user.get() # deply:ignore:DISALLOW_LAYER_DEPENDENCIES
import requests # deply:ignore:DISALLOWED_EXTERNAL_IMPORT
# File-level suppression (at the top of the file)
# deply:ignore-file:ENFORCE_INHERITANCE
How to Contribute
Feel free to contribute to this project by opening an issue or submitting a pull request! Together, we can make Deply a powerful tool for the Python community.
Running Tests
Use the following commands for local quality checks:
make check
make test
make mutation
make lint
make typing
make security
make pre-commit
Or run unittest directly:
python -m unittest discover tests
Roadmap
See the verified technical roadmap for current priorities, evidence, and implementation conditions.
Further Documentation
- Core Concepts - Explains layers, rules and violations in more details.
- Configuration - Reference for all available settings in a depfile
- Collectors - Reference for which collectors are available in Deply to define your layers.
- Rules - Lists the different rule types supported by Deply
- Mermaid Diagrams - Overview of the diagram generation capabilities
- Command Line Interface - Advice for using the CLI
- Agent Skill - Install and use the Deply Config Agent Skill
- Architecture Styles - Compare 21 architecture and application pattern recipes
- FastAPI - Configure layered FastAPI boundaries
- Full Stack FastAPI Template - Verified baseline for FastAPI's official template
- Django - Configure Django model, view, and domain boundaries
- Flask - Configure Flask route, blueprint, and persistence boundaries
Author
License
See the LICENSE file for details.
Release files for deply 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deply-1.1.2.tar.gz | 73.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deply-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 161.3 kB
Release files / deply-1.1.2.tar.gz
| Download URL | deply-1.1.2.tar.gz |
|---|---|
| Size | 73.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc7a12d19359a8aab57ab99b04eea5c6bfd523a5830145ec66b3f52645506c9f
|
|
BLAKE2b-256 checksum How to use checksums |
8acadbdc7e545f9e2ae9d6d993c5adf8602dcd1f6fb9a10863423678dd157502
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / deply-1.1.2-py3-none-any.whl
| Download URL | deply-1.1.2-py3-none-any.whl |
|---|---|
| Size | 88.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4393ab49ecfdcab7974ed67ee3401d386c21910aa9bc7e06c96de9e91a369877
|
|
BLAKE2b-256 checksum How to use checksums |
c95b3a098b03c43770d7fdab4d282a43b761a55c957154cdc78734686675cf8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|