Getting Started
Installation
Setup
Tach allows you to configure where you want to place module boundaries in your project.
You can do this interactively - run:
Mark each module boundary with ‘Enter’. You can mark all of your top-level Python source packages, or just a few which you want to isolate.
If your Python code lives below your project root, or if you are working in a monorepo with multiple Python packages, mark your Python source roots using the ‘s’ key.
This will create the config file for your project, tach.toml
.
Once you’ve marked all the modules you want to enforce dependencies between, run:
Dependencies that exist between each module you’ve marked will be written to tach.toml
.
Check out what Tach has found!
Note: Your ‘project root’ directory (where tach.toml
is) will be treated as a module boundary, and can show up as <root>
.
Enforcement
Tach comes with a command to enforce the boundaries that you just set up! From the root of your Python project, run:
You will see:
You can validate that Tach is working by either:
- Commenting out an item in a
depends_on
key intach.toml
- By adding an import between modules that didn’t previously import from each other.
Give both a try and run tach check
again. This will generate an error:
Each error indicates an import which violates your dependencies. If your terminal supports hyperlinks, click on the file path to go directly to the error.
Tach can easily be added to your CI pipeline, pre-commit hooks, and VS Code.
Extras
Visualize your dependency graph.
Tach will generate a graph of your dependencies. Here’s what this looks like for Tach:
Note that this graph is generated remotely with the contents of your tach.toml
when running tach show --web
.
If you would like to use the GraphViz DOT format locally, simply running tach show
will generate tach_module_graph.dot
in your working directory.
You can view the dependencies and usages for a given path:
e.g.:
Tach also supports: