-
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 #428 from gauge-sh/rebrand-strict-mode
[0.15.0] Move from 'strict mode' to explicit interfaces
- Loading branch information
Showing
27 changed files
with
527 additions
and
189 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
[package] | ||
name = "tach" | ||
version = "0.14.4" | ||
version = "0.15.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
|
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
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
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: Interfaces | ||
--- | ||
|
||
A module can adopt a public interface by matching interface rules in [`tach.toml`](./configuration#interfaces). | ||
|
||
## How does it work? | ||
|
||
When Tach is checking imports from a module with a [public interface](./configuration#interfaces), it will verify that the import matches one of the `expose` patterns. | ||
This prevents other modules from becoming coupled to implementation details, and makes future changes easier. | ||
|
||
## Example | ||
|
||
Given modules called 'core' and 'domain', we may have `tach.toml` contents like this: | ||
|
||
```toml | ||
[[modules]] | ||
path = "domain" | ||
depends_on = [ | ||
{ path = "core" } | ||
] | ||
|
||
[[modules]] | ||
path = "core" | ||
depends_on = [] | ||
|
||
[[interfaces]] | ||
expose = ["get_data"] | ||
from = ["core"] | ||
``` | ||
|
||
Then, in `domain.py`, we may have: | ||
|
||
```python | ||
from core.main import DataModel # This import fails | ||
|
||
DataModel.objects.all() | ||
``` | ||
|
||
This import would **fail** `tach check` with the following error: | ||
|
||
```shell | ||
❌ domain.py[L1]: Module 'core' is in strict mode. Only imports from the public interface of this module are allowed. The import 'core.main.DataModel' (in module 'parsing') is not public. | ||
``` | ||
|
||
In this case, there is a public interface defined in `tach.toml` which includes a service method to use instead. | ||
|
||
```python | ||
from core import get_data # This import is OK | ||
|
||
get_data() | ||
``` | ||
|
||
`tach check` will now pass! | ||
|
||
```bash | ||
✅ All module dependencies validated! | ||
``` |
This file was deleted.
Oops, something went wrong.
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,5 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
__version__ = "0.14.4" | ||
__version__ = "0.15.0" | ||
|
||
__all__ = ["__version__"] |
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
Oops, something went wrong.