Skip to main content

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.

Static Badge Static Badge Static Badge Static Badge Static Badge

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.0.0 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 with light, medium, or strict architecture rules, validate it with deply validate, run analysis, and add Makefile/CI/docs integration.

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.
  • External Import Restrictions: Prevent selected layers from importing framework, persistence, or SDK packages.
  • Extensible and Configurable: Customize layers and rules for any Python project setup.
  • Mermaid Diagrams: Visualize your architecture and dependencies with Mermaid diagrams.
  • Error Suppression: Suppress specific rule violations with inline comments.
  • Config Validation: Validate deply.yaml explicitly or automatically before analysis.
  • Architecture Recipes: Start from validated configurations for 21 architecture and application patterns.

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 🚀

A plan to evolve Deply into a must-have architectural guardian for Python projects:

🔲 Skip violations skip_violations
🔲 Interactive config setup (deply init wizard)
🔲 GitHub Actions/GitLab CI templates
# deply:ignore suppression comments
✅ Config validation command (deply validate) ✅ Parallel file analysis
✅ Custom collectors system
🔲 Dependency graph caching
🔲 Custom rules system
✅ FastAPI/Django/Flask configuration recipes ✅ Architecture and application pattern recipes ✅ LLM skill creation helpers ✅ Third-party import restrictions (disallow_external_imports)

See the verified technical roadmap for 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

Archil Abuladze

License

See the LICENSE file for details.

Download files

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

Source Distribution

deply-1.1.0.tar.gz (70.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deply-1.1.0-py3-none-any.whl (84.5 kB view details)

Uploaded Python 3

File details

Details for the file deply-1.1.0.tar.gz.

File metadata

  • Download URL: deply-1.1.0.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for deply-1.1.0.tar.gz
Algorithm Hash digest
SHA256 57ba4e70965a1d41d94df60cf2e1d55ffdb21082e687a96329b4594c70b012c9
MD5 b4e1c23b4378d3055bda32f4afa02c60
BLAKE2b-256 4671bf417328e9bde3eb10f7a4344ae8a3ce7a88f1c1c7f1debedca4cd173b37

See more details on using hashes here.

File details

Details for the file deply-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: deply-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 84.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for deply-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20c1396f50d1949629e497aa6677850ebc40b1b042aaec1dd77a447fb6f70685
MD5 8d0c1df3bce3433f16e19e5a247d7969
BLAKE2b-256 1535365f4bc250cfc16dab424f2092237064b184cb96165fce02343e16eea3c0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

0.9.1

2 files

0.9.0

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.2

2 files

0.6.0

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.4.1

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.0

2 files

0.1.6.2

2 files

0.1.6.1

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page