From 99ceb31008e9a63834412ccec3f8ebf36a652417 Mon Sep 17 00:00:00 2001 From: Mattias Carlsson Date: Mon, 26 Aug 2024 23:12:43 +0200 Subject: [PATCH] The new "Format with Black" step runs Black in check mode (--check) and shows the diff of any formatting changes (--diff). This will cause the workflow to fail if there are any formatting issues, but won't actually change the files. If you want Black to automatically format the files, you can remove the --check and --diff flags. --- .github/workflows/python-package.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 16a5607..c32c4d8 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,6 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - name: Python package on: @@ -28,7 +25,7 @@ jobs: run: | pip install -e . python -m pip install --upgrade pip - python -m pip install flake8 pytest + python -m pip install flake8 pytest black if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | @@ -36,6 +33,9 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --max-complexity=10 --max-line-length=127 --statistics + - name: Format with Black + run: | + black --check --diff . - name: Test with pytest run: | pytest