运行pre-commit钩子入口。允许运行pre-commit钩子以满足文本编辑格式化/代码检查需求。
项目描述
运行 pre-commit 钩子入口。允许运行pre-commit钩子以满足文本编辑格式化/代码检查需求。
危险区域
重要: 这是一个高度实验性的工具,因为 pre-commit 内部并不打算在其他脚本中使用。在新的pre-commit版本发布后可能会损坏。
请谨慎使用!
要求
Python 3.7或更高版本
pre-commit 2.19.0或更高版本
许可协议
pre-commit-run-hook-entry 适用于 BSD-3-Clause 许可协议。
安装
pip install pre-commit-run-hook-entry
用法
pre-commit-run-hook-entry HOOK [ARGS]
pre-commit-which-hook-entry HOOK
先决条件
pre-commit-run-hook-entry 仅在可执行 pre-commit run --all HOOK 的目录中工作。
VS Code 集成
以下示例说明如何配置 VS Code 使用 black、flake8 和 mypy 预提交钩子进行格式化和代码检查:
{
"python.formatting.provider": "black",
"python.formatting.blackPath": "pre-commit-run-hook-entry",
"python.formatting.blackArgs": ["black"],
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Path": "pre-commit-run-hook-entry",
"python.linting.flake8Args": ["flake8"],
"python.linting.mypyEnabled": true,
"python.linting.mypyPath": "pre-commit-run-hook-entry",
"python.linting.mypyArgs": ["mypy"]
}
Sublime Text 3 集成
sublack
从某一点开始,sublack 内置了预提交集成,但它似乎不尊重 pyproject.toml 中的设置,要修复此问题,请使用 pre-commit-run-black-entry 作为 sublack.black_command。
{
"sublack.black_command": "pre-commit-run-black-entry"
}
SublimeLinter-flake8
{
"SublimeLinter.linters.flake8.executable": "pre-commit-run-hook-entry",
"SublimeLinter.linters.flake8.args": ["--", "flake8"]
}
SublimeLinter-contrib-mypy
{
"SublimeLinter.linters.mypy.executable": "pre-commit-run-hook-entry",
"SublimeLinter.linters.mypy.args": ["--", "mypy"]
}
SublimeJsPrettier
首先,您需要使用以下命令找到 prettier 钩子入口的路径:
pre-commit-which-hook-entry prettier
然后,将命令输出(<OUTPUT>)粘贴到插件配置中:
{
"js_prettier": {
"prettier_cli_path": "<OUTPUT>"
}
}
SublimeLinter-eslint
首先,您需要使用以下命令找到 eslint 钩子入口的路径:
pre-commit-which-hook-entry eslint
然后,将命令输出(<OUTPUT>)粘贴到插件配置中:
{
"SublimeLinter.linters.eslint.executable": "<OUTPUT>",
"SublimeLinter.linters.eslint.env": {
"NODE_PATH": "<OUTPUT>/../../lib/node_modules"
}
}
重要:如果您为 eslint 钩子使用任何 additionalDependencies,您需要配置 NODE_PATH,以便插件能够找到这些依赖项。
问题和功能请求
请随时在 GitHub 上提交新的问题或功能请求 在此
项目详情
关闭
哈希 for pre_commit_run_hook_entry-1.0.0b1-py3-none-any.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 527992fef63561541c86ae228db657f402be48133fb70ec22197844a1d6d644f |
|
MD5 | 487fc2f0bf7baa038b0e619b3bdc3197 |
|
BLAKE2b-256 | 1c63a095cb1a781339743ffc80295a31f941d5318d5fd274e3f73f8fb83ce626 |