Run pre-commit hook entry. Allow to run pre-commit hooks for text editor formatting / linting needs
Project description
Run pre-commit hook entry. Allow to run pre-commit hooks for text editor formatting / linting needs.
Danger Zone
IMPORTANT: This is highly experimental tool as pre-commit internals does not intend to be used in other scripts. It might be broken after new pre-commit release.
TO USE WITH CAUTION!
Requirements
Python 3.7 or later
pre-commit 2.7.1 or later
License
pre-commit-run-hook-entry is licensed under the terms of BSD-3-Clause license.
Installation
pip install pre-commit-run-hook-entry
Usage
pre-commit-run-hook-entry HOOK [ARGS]
pre-commit-which-hook-entry HOOK
Prerequisites
pre-commit-run-hook-entry only works in directories, where pre-commit run --all HOOK is executable.
VS Code Integration
Example below illustrates how to configure VS Code to use black, flake8 & mypy pre-commit hooks for formatting & linting,
{
"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 Integration
sublack
From one point sublack has builtin pre-commit integration, but it seems do not respect settings from pyproject.toml, to fix this use pre-commit-run-black-entry as 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
First, you need to find out path to prettier hook entry with,
pre-commit-which-hook-entry prettier
Then, paste command output (<OUTPUT>) into plugin config,
{
"js_prettier": {
"prettier_cli_path": "<OUTPUT>"
}
}
SublimeLinter-eslint
First, you need to find out path to eslint hook entry with,
pre-commit-which-hook-entry eslint
Then, paste command output (<OUTPUT>) into plugin config,
{
"SublimeLinter.linters.eslint.executable": "<OUTPUT>",
"SublimeLinter.linters.eslint.env": {
"NODE_PATH": "<OUTPUT>/../../lib/node_modules"
}
}
IMPORTANT: If you’re using any additionalDependencies for eslint hook, you need to configure NODE_PATH, so plugin will be able to find out given dependencies.
Issues & Feature Requests
Feel free to submit new issue or feature request at GitHub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pre-commit-run-hook-entry-1.0.0a3.tar.gz
.
File metadata
- Download URL: pre-commit-run-hook-entry-1.0.0a3.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27f3083777ba5ad1f7ee30d6fb120d4ba5ec3667fa7a5fae49e0ad7c558fb111 |
|
MD5 | c4ac437d6b05a5846b509d4ba7eee5ec |
|
BLAKE2b-256 | 1a464cbecfe3bd7846dcebb17190db804c4d1c1ec0a3df28d166d2fb837a1941 |
File details
Details for the file pre_commit_run_hook_entry-1.0.0a3-py3-none-any.whl
.
File metadata
- Download URL: pre_commit_run_hook_entry-1.0.0a3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6084c38e5482796fe4e0ea71ae43a1808884429778f4e131ff4a7528f65c0e66 |
|
MD5 | aef11250aaa9e07e66050a5420a15d41 |
|
BLAKE2b-256 | 71f8407f9090fd33e8e8afe065a411ebc8e2039dd10b3aa414a0148fe4bbcfd7 |