-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from gauge-sh/exact-config
strict -> exact, configurable in tach.yml, docs updates, fix argv[0] assumption
- Loading branch information
Showing
12 changed files
with
151 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,3 +164,4 @@ cython_debug/ | |
|
||
.python-version | ||
.env.leave | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,65 @@ | ||
# Getting Started | ||
### Installation | ||
```bash | ||
pip install tach | ||
``` | ||
### Setup | ||
Tach allows you to configure what is and is not considered a package. By default, Tach will identify and create configuration for all top level packages it finds. | ||
|
||
## Installation | ||
You can do this interactively! From the root of your python project, run: | ||
```bash | ||
tach pkg | ||
# Up/Down: Navigate Ctrl + Up: Jump to parent Right: Expand Left: Collapse | ||
# Ctrl + c: Exit without saving Ctrl + s: Save packages Enter: Mark/unmark package Ctrl + a: Mark/unmark all siblings | ||
``` | ||
Mark and unmark each package as needed, depending on what you want to define boundaries for. | ||
|
||
[PyPi package](https://pypi.org/project/tach/) | ||
Once you have marked all the packages you want to enforce constraints between, run: | ||
```bash | ||
tach sync | ||
``` | ||
This will create the root configuration for your project, `tach.yml`, with the dependencies that currently exist between each package you've marked. | ||
|
||
You can then see what Tach has found by viewing the `tach.yml`'s contents: | ||
``` | ||
cat tach.yml | ||
``` | ||
|
||
Install tach into a Python environment with `pip` | ||
Note: Dependencies on code that are not marked as packages are out of the scope of Tach and will not be enforced. | ||
|
||
### Enforcement | ||
Tach comes with a simple cli command to enforce the boundaries that you just set up! From the root of your Python project, run: | ||
```bash | ||
pip install tach | ||
tach check | ||
``` | ||
|
||
Verify your installation is working correctly | ||
You will see: | ||
```bash | ||
tach -h | ||
✅ All package dependencies validated! | ||
``` | ||
|
||
## Adding to a Project | ||
You can validate that Tach is working by either commenting out an item in a `depends_on` key in `tach.yml`, or by adding an import between packages that didn't previously import from each other. | ||
|
||
If you are adding `tach` to an existing project, you have two main options: | ||
Give both a try and run `tach check` again. This will generate an error: | ||
```bash | ||
❌ path/file.py[LNO]: Cannot import 'path.other'. Tags ['scope:other'] cannot depend on ['scope:file']. | ||
``` | ||
|
||
1. Use [`tach pkg`](usage.md#tach-pkg) to interactively set up packages, and [`tach sync`](usage.md#tach-sync) to automatically set up dependency rules. | ||
2. Manually configure your [packages](configuration.md#packageyml) and [dependency rules](configuration.md#tachyml) | ||
### Extras | ||
|
||
## Checking Boundaries | ||
If an error is generated that is an intended dependency, you can sync your actual dependencies with `tach.yml`: | ||
```bash | ||
tach sync | ||
``` | ||
After running this command, `tach check` will always pass. | ||
|
||
If your configuration is in a bad state, from the root of your python project you can run: | ||
```bash | ||
# From the root of your Python project | ||
tach check | ||
tach clean | ||
``` | ||
This will wipe all the configuration generated and enforced by Tach. | ||
|
||
|
||
After guarding your project, running `tach check` from the root will check all imports to verify that packages remain correctly decoupled. | ||
Tach also supports: | ||
- [Manual file configuration](https://gauge-sh.github.io/tach/configuration/) | ||
- [Strict public interfaces for packages](https://gauge-sh.github.io/tach/strict-mode/) | ||
- [Inline exceptions](https://gauge-sh.github.io/tach/tach-ignore/) | ||
- [Pre-commit hooks](https://gauge-sh.github.io/tach/usage/#tach-install) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[project] | ||
name = "tach" | ||
version = "0.2.3" | ||
version = "0.2.4" | ||
authors = [ | ||
{ name="Caelean Barnes", email="[email protected]" }, | ||
{ name="Evan Doyle", email="[email protected]" }, | ||
|
@@ -16,6 +16,7 @@ classifiers = [ | |
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
|
Oops, something went wrong.