tach
配x未受欢迎的:这个存储库不再积极维护。问题和拉的请求可能不会收到答复。
tach是用生锈写的依赖性和接口的Python工具。
tach的灵感来自模块化整体建筑。
文档
tach可以强制执行:
- ?进口仅来自声明的依赖项
- ?交叉模块调用使用公共接口
- ⛓️?依赖图中没有周期
tach是:
入门
安装
pip install tach
设置
tach将指导您完成初始项目设置。
跑步:
tach init
介绍消息后,您将看到一个文件树接口,允许您交互式配置项目。
使用箭头键进行导航,并将每个模块边界标记为“ Enter”。您可以标记所有顶级Python软件包,或仅需跟踪的一些。
常见问题:什么是模块?
如果您的Python代码居住在项目根以下,或者您在带有多个Python软件包的MonorePo中工作,请使用“ S”键标记Python源根。
执法
tach带有CLI命令来强制您刚刚设置的边界!从Python项目的根源中,运行:
tach check
您会看到:
✅ All modules validated !
您可以通过以下方式验证tach正在工作:
- 从
tach .toml中的depends_on键中删除项目,或将其标记为弃用 - 通过在模块之间添加以前没有相互导入的导入。
两者都尝试再次运行tach check 。这将产生一个错误:
tach .filesystem\’. Module \’ tach \’ cannot depend on \’ tach .filesystem\’.\”>
tach /check.py[L8]: Cannot use \' tach .filesystem \' . Module \' tach \' cannot depend on \' tach .filesystem \' .
每个错误表示违反您的依赖性的导入。如果您的终端支持超链接,请单击文件路径直接进入错误。
当检测到错误时, tach check将使用非零代码退出。它可以很容易地与CI/CD,预先承诺的钩子和VS代码等组合在一起!
额外
可视化依赖图。
tach show [--web]
tach将生成您的依赖性图。这就是tach的样子:
请注意,该图是在运行tach show --web时用tach .toml的内容远程生成的。
如果您想在本地使用GraphViz点格式,那么简单地运行tach show将在您的工作目录中生成tach _module_graph.dot 。
您可以查看给定路径的依赖项和用法:
tach report my_package/
# OR
tach report my_module.py\”>
tach report my_package/
# OR
tach report my_module.py
例如:
tach /filesystem
[Dependencies of \’python/ tach /filesystem\’]
python/ tach /filesystem/install.py[L6]: Import \’ tach .hooks.build_pre_commit_hook_content\’
python/ tach /filesystem/project.py[L5]: Import \’ tach .constants.CONFIG_FILE_NAME\’
…
——————————-
[Usages of \’python/ tach /filesystem\’]
python/ tach /cache/access.py[L8]: Import \’ tach .filesystem.find_project_config_root\’
python/ tach /cache/setup.py[L7]: Import \’ tach .filesystem.find_project_config_root\’
…\”>
> tach report python/ tach /filesystem [Dependencies of \' python/ tach /filesystem \' ] python/ tach /filesystem/install.py[L6]: Import \' tach .hooks.build_pre_commit_hook_content \' python/ tach /filesystem/project.py[L5]: Import \' tach .constants.CONFIG_FILE_NAME \' ... ------------------------------- [Usages of \' python/ tach /filesystem \' ] python/ tach /cache/access.py[L8]: Import \' tach .filesystem.find_project_config_root \' python/ tach /cache/setup.py[L7]: Import \' tach .filesystem.find_project_config_root \' ...
tach还支持:
- 模块的公共接口
- 贬低个人依赖性
- 分层体系结构
- 增量采用
- 生成JSON依赖图
- monorepos和名称空间软件包
- 域名
- 内联的“忽略”评论
- 预先承诺的钩子
文档中的更多信息。 tach记录可以退出的匿名用法统计信息。如果您有任何反馈,我们很想谈!
如果您有任何疑问或遇到任何问题,请通过提交GitHub问题告诉我们!
