Giter Site home page Giter Site logo

dep-check's Introduction

dep-check

image CircleCI

Version: Pre-alpha

dep-check is a Python dependency checker. First write rules on which module can import what, then dep-check parses each source file to verify that everything is in order. You can also draw a dependency graph for your project.

Free software: MIT license

Supported languages

By default, the tool assumes it's operating on a Python project.

Installation

To install dep-check, run this command:

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 installed, this Python installation guide can guide you through the process.

You can also see other installation methods.

Usage

Build your config file

dep_check build <ROOT_DIR> [-o config.yaml] [--lang LANG]
Argument Description Optional Default
ROOT_DIR The root directory of your project, containing you source files N/A
-o / --output The output file you want (yaml format) ✔️ dependency_config.yaml
--lang The language your project is written in ✔️ python

This command lists the imports of each module in a yaml file. Using this file, write some dependency rules on which module can import what, using wildcards.

Here is an example:

---

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
  • Write * to include any string, even an empty one
  • Using the % character after a module name (e.g. my_module%) includes this module along with its sub-modules.

Here, for instance, we tell the tool that dep_check.infra.io can import dep_check.use_cases, but also dep_check.use_cases.build, dep_check.use_cases.check and so on.

To see all the supported wildcards, check the User Manual.

Check your config

Once your config file is ready, run

dep_check check <ROOT_DIR> [-c config.yaml] [--lang LANG]
Argument Description Optional Default
ROOT_DIR The root directory of your project, containing you source files N/A
-c / --config The input file in which you wrote the dependency rules (yaml format) ✔️ dependency_config.yaml
--lang The language your project is written in ✔️ python

The command reads the configuration file, and parse every source file. It then verifies, for each file, that every import is authorized by the rules in the configuration file.

When it's done, it writes a report on the console, listing import errors by module and unused rules:

report

Draw a dependency graph

# You need to have graphviz installed to run this
dep_check graph <ROOT_DIR> [-o file.svg/dot] [-c config.yaml] [--lang LANG]
Argument Description Optional Default
ROOT_DIR The root directory of your project, containing you source files N/A
-o / --output The output file you want (svg or dot format) ✔️ dependency_graph.svg
-c / --config The graph configuration file, to write options that you want (yaml format) ✔️ None
--lang The language your project is written in ✔️ python

Note : if you generate a svg file, a dot file is 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 for more information.

Contributing

If you want to make a contribution, be sure to follow the Contribution guide.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template

Authors & contributors

Check out all the Authors and contributors of this project.

dep-check's People

Contributors

imonor avatar lumautomation avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.