diff --git a/.github/workflows/ruff.yml b/.github/workflows/prek.yml similarity index 58% rename from .github/workflows/ruff.yml rename to .github/workflows/prek.yml index e0a5cda..9daf59d 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/prek.yml @@ -1,4 +1,4 @@ -name: Ruff +name: Prek on: push: branches: main @@ -6,8 +6,10 @@ on: branches: "*" jobs: - ruff: + prek: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: astral-sh/ruff-action@v3 + - uses: j178/prek-action@v1 + with: + extra-args: '--all-files' diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index f058e43..c676044 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -15,4 +15,4 @@ jobs: - uses: astral-sh/setup-uv@v5 - run: uv python install - run: uv sync - - run: uv run pytest -vv \ No newline at end of file + - run: uv run pytest -vv diff --git a/README.md b/README.md index cc3ca95..f8c504e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # python-template -This project uses [`uv`](https://github.com/astral-sh/uv), which can be installed in one line: +This project uses [`uv`](https://github.com/astral-sh/uv), which can be installed in one line: ```bash # On macOS and Linux. curl -LsSf https://astral.sh/uv/install.sh | sh @@ -19,7 +19,7 @@ uv sync --dev source .venv/bin/activate ``` -For development, make sure to install the project with the `-e` flag +For development, make sure to install the project with the `-e` flag so the source code isn't distributed to `.venv`: ``` uv pip install -e . diff --git a/prek.toml b/prek.toml new file mode 100644 index 0000000..3e8227e --- /dev/null +++ b/prek.toml @@ -0,0 +1,18 @@ +[[repos]] +repo = "builtin" +hooks = [ + { id = "trailing-whitespace", args = ["--markdown-linebreak-ext=md"] }, + { id = "end-of-file-fixer" }, + { id = "check-yaml" }, + { id = "check-toml" }, + { id = "check-merge-conflict" }, + { id = "check-added-large-files" }, +] + +[[repos]] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.15.5" +hooks = [ + { id = "ruff-check", args = ["--fix"] }, + { id = "ruff-format" }, +] diff --git a/src/python_template/cli.py b/src/python_template/cli.py index 3f38864..ef952ba 100644 --- a/src/python_template/cli.py +++ b/src/python_template/cli.py @@ -1,4 +1,3 @@ - def main(): print("Hello from python-template") diff --git a/src/python_template/utils.py b/src/python_template/utils.py index 21d11ce..cf68624 100644 --- a/src/python_template/utils.py +++ b/src/python_template/utils.py @@ -1,4 +1,2 @@ - - def foo(): - return "foo" \ No newline at end of file + return "foo" diff --git a/tests/test_utils.py b/tests/test_utils.py index da861d8..e186805 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,6 @@ from python_template.utils import foo + def test_foo(): result = foo() - assert result == "foo" \ No newline at end of file + assert result == "foo"