diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2f45fbc1f..ce94cdc09 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -33,13 +33,15 @@ "vsliveshare.vsliveshare" ], "settings": { - "ruff.lint.run": "onSave", - "ruff.configurationPreference": "filesystemFirst", - "editor.defaultFormatter": "charliermarsh.ruff", - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.fixAll": "explicit" - } + "[python]": { + "ruff.lint.run": "onSave", + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.formatOnSave": false, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit" + } + }, + "ruff.configurationPreference": "filesystemFirst" } } }, diff --git a/.devcontainer/scripts/installations.sh b/.devcontainer/scripts/installations.sh index 715148094..5a8ee3aa3 100644 --- a/.devcontainer/scripts/installations.sh +++ b/.devcontainer/scripts/installations.sh @@ -38,6 +38,9 @@ poetry completions zsh > ~/.zfunc/_poetry cd /workspace poetry install +# Install pre-commit hooks +poetry run pre-commit install + # Poe the Poet plugin tab completions touch ~/.zfunc/_poe poetry run poe _zsh_completion > ~/.zfunc/_poe diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..2f775686d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.5 + hooks: + # Run the linter + - id: ruff + args: [ --fix ] + # Run the formatter + - id: ruff-format \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 005883ce9..39aba7fe6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2758,4 +2758,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"] [metadata] lock-version = "2.0" python-versions = "~3.10.9" -content-hash = "443df8a67497588c1801bfac747fde95ecaffda93675b6f038906750e891316b" +content-hash = "94c0fc0df7115b07d314521cd48aefc25a5bee81c7b0fa2477a86bb4db3ede81" diff --git a/pyproject.toml b/pyproject.toml index e44d4352e..662a8a46c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,7 @@ jinja2-cli = { version = "^0.8.2", extras = ["yaml"] } mypy = "1.11.2" monkeytype = "23.3.0" poethepoet = "^0.24.4" +pre-commit = "^3.7.1" ruff = "^0.6.9" # stubs libraries to keep mypy happy