# dep-check
[](https://pypi.python.org/pypi/dep-check) [](https://circleci.com/gh/lumapps/dep-check/tree/master)
**dep-check** is a Python dependency checker. It lets you write rules to define what each module can import, **dep-check** can then parse each source file in your project to verify everything is in order. You can also use it to draw a dependency graph for your project.

**Free software:** MIT license
## Supported languages
* [Python](https://www.python.org/)
By default, the tool assumes it's operating on a Python project.
## Installation
To install **dep-check**, run this command:
```sh
pip install dep-check
```
This is the preferred method to install **dep-check**, as it always
installs the most recent stable release.
If you don't have [pip](https://pip.pypa.io) installed, this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through the process.
You can also see [other installation methods](https://github.com/lumapps/dep-check/blob/master/doc/installation.md).
## Usage
### Build your configuration file
```sh
dep_check build <ROOT_DIR> [-o config.yaml] [--lang LANG]
```
Argument | Description | Optional | Default
-------- | ----------- | -------- | -------
ROOT_DIR | The project root directory, containing the source files | :x: | *N/A*
-o / --output | The output file (yaml format) | :heavy_check_mark: | dependency_config.yaml
--lang | The language the project is written in | :heavy_check_mark: | python
This command lists the imports of each module in a yaml file. Use this file as a starting point to write dependency rules on which module can import what, using wildcards.
Here is an example of additional rules added to the initial yaml file:
```yaml
---
dependency_rules:
'*':
- dep_check.models
- dep_check.dependency_finder
- dep_check.checker
dep_check.infra.io:
- dep_check.use_cases%
- jinja2
- yaml
dep_check.infra.std_lib_filter:
- dep_check.use_cases.interfaces
dep_check.use_cases%:
- dep_check.use_cases.app_configuration
- dep_check.use_cases.interfaces
dep_check.main:
- '*'
lang: python
local_init: false
```
* Use `*` to include any string, even an empty one.
* Use `%` after a module name (e.g. `my_module%`) to include this module along with its sub-modules.
Here, for instance, the configuration file defines that `dep_check.infra.io` can import `dep_check.use_cases`, along with `dep_check.use_cases.build`, `dep_check.use_cases.check`, and so on.
*To see all the supported wildcards, check the [User Manual](https://github.com/lumapps/dep-check/blob/master/doc/usage.md#write-your-own-configuration-file).*
### Check your configuration
Once your config file is ready, run
```sh
dep_check check <ROOT_DIR> [-c config.yaml] [--lang LANG]
```
Argument | Description | Optional | Default
-------- | ----------- | -------- | -------
ROOT_DIR | The project root directory, containing the source files | :x: | *N/A*
-c / --config | The yaml file in which you wrote the dependency rules | :heavy_check_mark: | dependency_config.yaml
--lang | The language the project is written in | :heavy_check_mark: | python
The command reads the configuration file, and parses each source file. It then verifies, for each file, that every `import` is authorized by the rules defined in the configuration file.
When it's done, it writes a report on the console, listing import errors by module and unused rules:

### Draw a dependency graph
**You need to have graphviz installed to run this command**
```sh
dep_check graph <ROOT_DIR> [-o file.svg/dot] [-c config.yaml] [--lang LANG]
```
Argument | Description | Optional | Default
-------- | ----------- | -------- | -------
ROOT_DIR | The project root directory, containing the source files | :x: | *N/A*
-o / --output | The output file you want (svg or dot format) | :heavy_check_mark: | dependency_graph.svg
-c / --config | The graph configuration file containing options (yaml format) | :heavy_check_mark:| None
--lang | The language the project is written in | :heavy_check_mark: | python
*Note : if you generate a svg file, a dot file is also created in `/tmp/graph.dot`*
A lot of options are available to customize your graph (hide some modules, add layers etc.). Check the [User Manual](https://github.com/lumapps/dep-check/blob/master/doc/usage.md#add-options) for more information.
## Contributing
If you want to make a contribution, be sure to follow the [Contribution guide](https://github.com/lumapps/dep-check/blob/master/doc/contributing.md).
## Credits
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the
[audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template
## Authors & contributors
Check out all the [Authors and contributors](https://github.com/lumapps/dep-check/blob/master/doc/authors.md) of this project.
# CHANGELOG
## 3.0.1(2023-03-28)
### BUGFIX
- Use OrderedSet instead of set, in order to have a deterministic runs
## 3.0.0(2022-12-21)
### MAJOR
- Update python support, tested on 3.9, 3.10, 3.11.
- Add support of dynamic rules (see doc)
- Support multiple files and directories in parameters.
- Drop `error_on_unused` option (replaced by `unused_level`).
- Add `unused_level` option to choose the raise an error when unused rules are detected.
## 2.0.1(2022-06-02)
### MAJOR
- Drop go compatibility.
- Update python support, tested on 3.8, 3.9, 3.10.
- Add `error_on_unused` option to raise an error when unused rules are detected.
## 1.0.3(2019-08-26)
### BUGFIX
- The tool now works correctly with Go.
## 1.0.0 (2019-08-20)
### Modified
- The tool now writes a full report, displaying the number of errors, warnings and files.
- The commands have been simplified, to avoid too long command lines
### Added
- The tool now supports Go language
- Better documentation
## 0.2.0 (2019-07-16)
### Added
- You can now add layers to your graph.
- The tool now warns you if a rule in your configuration file is not used.
## 0.1.0 (2019-07-09)
- First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/lumapps/dep-check",
"name": "dep-check",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,Dependency,linter,architecture,quality,dep-check,dep_check",
"author": "LumApps",
"author_email": "core-devs@lumapps.com",
"download_url": "https://files.pythonhosted.org/packages/0e/64/3573fc67e5f9a9e5729873d2eb139a486eed841f5068178c2bd869dd0a06/dep_check-3.0.1.tar.gz",
"platform": null,
"description": "# dep-check\n\n[](https://pypi.python.org/pypi/dep-check) [](https://circleci.com/gh/lumapps/dep-check/tree/master)\n\n**dep-check** is a Python dependency checker. It lets you write rules to define what each module can import, **dep-check** can then parse each source file in your project to verify everything is in order. You can also use it to draw a dependency graph for your project.\n\n\n\n**Free software:** MIT license\n\n## Supported languages\n\n* [Python](https://www.python.org/)\n\nBy default, the tool assumes it's operating on a Python project.\n\n## Installation\n\nTo install **dep-check**, run this command:\n\n```sh\npip install dep-check\n```\n\nThis is the preferred method to install **dep-check**, as it always\ninstalls the most recent stable release.\n\nIf you don't have [pip](https://pip.pypa.io) installed, this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through the process.\n\nYou can also see [other installation methods](https://github.com/lumapps/dep-check/blob/master/doc/installation.md).\n\n## Usage\n\n### Build your configuration file\n\n```sh\ndep_check build <ROOT_DIR> [-o config.yaml] [--lang LANG]\n```\n\nArgument | Description | Optional | Default\n-------- | ----------- | -------- | -------\nROOT_DIR | The project root directory, containing the source files | :x: | *N/A*\n-o / --output | The output file (yaml format) | :heavy_check_mark: | dependency_config.yaml\n--lang | The language the project is written in | :heavy_check_mark: | python\n\nThis command lists the imports of each module in a yaml file. Use this file as a starting point to write dependency rules on which module can import what, using wildcards.\n\nHere is an example of additional rules added to the initial yaml file:\n\n```yaml\n---\n\ndependency_rules:\n'*':\n - dep_check.models\n - dep_check.dependency_finder\n - dep_check.checker\n\ndep_check.infra.io:\n - dep_check.use_cases%\n - jinja2\n - yaml\n\ndep_check.infra.std_lib_filter:\n - dep_check.use_cases.interfaces\n\ndep_check.use_cases%:\n - dep_check.use_cases.app_configuration\n - dep_check.use_cases.interfaces\n\ndep_check.main:\n - '*'\n\nlang: python\nlocal_init: false\n```\n\n* Use `*` to include any string, even an empty one.\n* Use `%` after a module name (e.g. `my_module%`) to include this module along with its sub-modules.\n\nHere, for instance, the configuration file defines that `dep_check.infra.io` can import `dep_check.use_cases`, along with `dep_check.use_cases.build`, `dep_check.use_cases.check`, and so on.\n\n*To see all the supported wildcards, check the [User Manual](https://github.com/lumapps/dep-check/blob/master/doc/usage.md#write-your-own-configuration-file).*\n\n### Check your configuration\n\nOnce your config file is ready, run\n\n```sh\ndep_check check <ROOT_DIR> [-c config.yaml] [--lang LANG]\n```\n\nArgument | Description | Optional | Default\n-------- | ----------- | -------- | -------\nROOT_DIR | The project root directory, containing the source files | :x: | *N/A*\n-c / --config | The yaml file in which you wrote the dependency rules | :heavy_check_mark: | dependency_config.yaml\n--lang | The language the project is written in | :heavy_check_mark: | python\n\nThe command reads the configuration file, and parses each source file. It then verifies, for each file, that every `import` is authorized by the rules defined in the configuration file.\n\nWhen it's done, it writes a report on the console, listing import errors by module and unused rules:\n\n\n\n### Draw a dependency graph\n\n**You need to have graphviz installed to run this command**\n\n```sh\ndep_check graph <ROOT_DIR> [-o file.svg/dot] [-c config.yaml] [--lang LANG]\n```\n\nArgument | Description | Optional | Default\n-------- | ----------- | -------- | -------\nROOT_DIR | The project root directory, containing the source files | :x: | *N/A*\n-o / --output | The output file you want (svg or dot format) | :heavy_check_mark: | dependency_graph.svg\n-c / --config | The graph configuration file containing options (yaml format) | :heavy_check_mark:| None\n--lang | The language the project is written in | :heavy_check_mark: | python\n\n*Note : if you generate a svg file, a dot file is also created in `/tmp/graph.dot`*\n\nA lot of options are available to customize your graph (hide some modules, add layers etc.). Check the [User Manual](https://github.com/lumapps/dep-check/blob/master/doc/usage.md#add-options) for more information.\n\n## Contributing\n\nIf you want to make a contribution, be sure to follow the [Contribution guide](https://github.com/lumapps/dep-check/blob/master/doc/contributing.md).\n\n## Credits\n\nThis package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the\n[audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template\n\n## Authors & contributors\n\nCheck out all the [Authors and contributors](https://github.com/lumapps/dep-check/blob/master/doc/authors.md) of this project.\n\n# CHANGELOG\n\n## 3.0.1(2023-03-28)\n\n### BUGFIX\n\n- Use OrderedSet instead of set, in order to have a deterministic runs\n\n## 3.0.0(2022-12-21)\n\n### MAJOR\n\n- Update python support, tested on 3.9, 3.10, 3.11.\n- Add support of dynamic rules (see doc)\n- Support multiple files and directories in parameters.\n- Drop `error_on_unused` option (replaced by `unused_level`).\n- Add `unused_level` option to choose the raise an error when unused rules are detected.\n\n## 2.0.1(2022-06-02)\n\n### MAJOR\n\n- Drop go compatibility.\n- Update python support, tested on 3.8, 3.9, 3.10.\n- Add `error_on_unused` option to raise an error when unused rules are detected.\n\n## 1.0.3(2019-08-26)\n\n### BUGFIX\n\n- The tool now works correctly with Go.\n\n## 1.0.0 (2019-08-20)\n\n### Modified\n\n- The tool now writes a full report, displaying the number of errors, warnings and files.\n- The commands have been simplified, to avoid too long command lines\n\n### Added\n\n- The tool now supports Go language\n- Better documentation\n\n## 0.2.0 (2019-07-16)\n\n### Added\n\n- You can now add layers to your graph.\n- The tool now warns you if a rule in your configuration file is not used.\n\n## 0.1.0 (2019-07-09)\n\n- First release on PyPI.\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Python Dependency Check Tool",
"version": "3.0.1",
"split_keywords": [
"python",
"dependency",
"linter",
"architecture",
"quality",
"dep-check",
"dep_check"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9933d22d7855aaf2f2b6e7c1df39940fc0b07832060c3f3fb0d21fa276500081",
"md5": "aa2c6db7d75426d2d1c1f06b17e422b8",
"sha256": "02c61ee1ae7c467a442ba5dcdf1a7de2b4ad0aaa8198077733e3e93a4da70b7a"
},
"downloads": -1,
"filename": "dep_check-3.0.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "aa2c6db7d75426d2d1c1f06b17e422b8",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 20440,
"upload_time": "2023-03-29T12:51:26",
"upload_time_iso_8601": "2023-03-29T12:51:26.542311Z",
"url": "https://files.pythonhosted.org/packages/99/33/d22d7855aaf2f2b6e7c1df39940fc0b07832060c3f3fb0d21fa276500081/dep_check-3.0.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0e643573fc67e5f9a9e5729873d2eb139a486eed841f5068178c2bd869dd0a06",
"md5": "4f783526aff91bad5bfc8f5809ab2a56",
"sha256": "78b63d76a6eeb5e11e1a00b24b80c71674dd6b0b51616b5255ca38c52fdde42a"
},
"downloads": -1,
"filename": "dep_check-3.0.1.tar.gz",
"has_sig": false,
"md5_digest": "4f783526aff91bad5bfc8f5809ab2a56",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 101617,
"upload_time": "2023-03-29T12:51:28",
"upload_time_iso_8601": "2023-03-29T12:51:28.234306Z",
"url": "https://files.pythonhosted.org/packages/0e/64/3573fc67e5f9a9e5729873d2eb139a486eed841f5068178c2bd869dd0a06/dep_check-3.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-29 12:51:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "lumapps",
"github_project": "dep-check",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "dep-check"
}