Relaxed layer architecture linter based on the import graph.
Project description
Layer Enforcer is a tool for linting your imports within the project.
The tool was designed to help maintain following order of things:
Dependencies always flow towards root of the tree. Often this is domain layer.
Dependencies may skip layers, as long as they flow in same direction. For instance, your web layer may import use cases from domain layer.
Infer layer from imports or module names. Say, if you import fastapi anywhere on the chain, the module is assigned to web layer, or maybe you want models to always be db layer.
Flexible layer structure. Preferably defined via config file.
Code is packaged by component. I.e. single component may contain code from the different layers.
Be warned, since this might not the best fit for you.
Installation
pip install layer-enforce
For Development
pip install -e .[test,lint]
Usage
layer-enforcer myproject myotherproject --layers layers.yaml
layers.yaml
An example of clean-architecture-ish layer layout for typical web app:
name: domain
submodules: ["entities", "use_cases"]
layers:
- name: service
submodules: ["services"]
layers:
- name: infrastructure
imports: ["stripe", "requests", "passlib"]
layers:
- name: db
imports: ["sqlalchemy", "psycopg2", "alembic"]
submodules: ["models", "memory", "database"]
- name: web
imports: ["fastapi", "jose"]
submodules: ["views", "schemas"]
- name: tasks
imports: ["celery"]
submodules: ["tasks"]
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 layer_enforcer-0.1.0.tar.gz
.
File metadata
- Download URL: layer_enforcer-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af29d82238149488db85e38f7950128ff5e5715eca70dda472901d4c84e4ae89 |
|
MD5 | a64a8352489b31dab00c4a5aa03e007d |
|
BLAKE2b-256 | 961c3b53f9c0e9cae35e9afcd6488153d6b9f1ea2247135bd083dec5096f3a63 |
File details
Details for the file layer_enforcer-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: layer_enforcer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbfde74023627475db81cb87578cf8114b9fb9a4c71f5151cd1524cdcec2bb6e |
|
MD5 | 44e501eb55bb3d42735f403f4dd796fe |
|
BLAKE2b-256 | 030392768e2c0fae46d5d47bdf9d26856297d8f9b9f0f8abefe2b6df18763e75 |