mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-12-12 08:23:49 +02:00
Add pre-commit to automatically run formatting when committing
This commit is contained in:
parent
7d07967574
commit
25168ba6e1
28
.pre-commit-config.yaml
Normal file
28
.pre-commit-config.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
# See https://pre-commit.com for more information
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
name: " 🐘 Check for added large files"
|
||||
- id: check-toml
|
||||
name: " ✔️ Check TOML"
|
||||
- id: check-yaml
|
||||
name: " ✔️ Check YAML"
|
||||
args:
|
||||
- --unsafe
|
||||
- id: check-json
|
||||
name: " ✔️ Check JSON"
|
||||
- id: trailing-whitespace
|
||||
name: " ✂️ Trim trailing whitespaces"
|
||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||
rev: v0.0.277
|
||||
hooks:
|
||||
- id: ruff
|
||||
name: " ⚡️ Formatting code with Ruff"
|
||||
args:
|
||||
- --fix
|
||||
|
||||
ci:
|
||||
autofix_commit_msg: 🎨 [pre-commit] Auto format
|
||||
autoupdate_commit_msg: ⬆ [pre-commit] pre-commit auto update
|
@ -33,6 +33,8 @@ git clone https://github.com/LibreTranslate/LibreTranslate.git
|
||||
cd LibreTranslate
|
||||
```
|
||||
|
||||
Hatch will automatically install the required dependencies in a virtual environment, and enable [`pre-commit`](https://pre-commit.com/), which will run before each commit to run formatting.
|
||||
|
||||
Run in development:
|
||||
|
||||
```bash
|
||||
@ -72,6 +74,12 @@ You can also run the tests on multiple python versions:
|
||||
hatch run all:test
|
||||
```
|
||||
|
||||
You can clean the virtual environment with:
|
||||
|
||||
```bash
|
||||
hatch env prune
|
||||
```
|
||||
|
||||
## Run with Docker
|
||||
|
||||
Linux/macOS: `./run.sh [args]`
|
||||
|
@ -65,7 +65,7 @@ ltmanage = "libretranslate.manage:manage"
|
||||
test = [
|
||||
"pytest >=7.2.0",
|
||||
"pytest-cov",
|
||||
"ruff ==0.0.277",
|
||||
"pre-commit >=3.0.0",
|
||||
"types-requests",
|
||||
]
|
||||
|
||||
@ -83,13 +83,16 @@ History = "https://github.com/LibreTranslate/LibreTranslate/releases"
|
||||
features = [
|
||||
"test",
|
||||
]
|
||||
post-install-commands = [
|
||||
"pre-commit install",
|
||||
]
|
||||
|
||||
|
||||
[tool.hatch.envs.default.scripts]
|
||||
dev = "python main.py {args}"
|
||||
locales = "python scripts/compile_locales.py"
|
||||
fmt = [
|
||||
"ruff libretranslate scripts --fix",
|
||||
"pre-commit run --all --all-files",
|
||||
]
|
||||
test = [
|
||||
"fmt",
|
||||
|
Loading…
Reference in New Issue
Block a user