From ee7e20ffc0366a4d5cc1717d13dc1dd2766b51cc Mon Sep 17 00:00:00 2001 From: Winston Sung Date: Fri, 23 Aug 2024 01:06:04 +0800 Subject: [PATCH] Migrate to Black Python code formatter Change-Id: If9b79f4a3d4bd194291dd2293ba564a3aea65012 --- .github/workflows/black.yml | 33 +++++++++++++++++++++++++++++++++ .github/workflows/pylint.yml | 2 +- pyproject.toml | 1 + requirements_dev.txt | 4 ++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/black.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 0000000..182659d --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,33 @@ +name: Black + +on: + pull_request: + push: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.11" ] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements_dev.txt + - name: Formatting the code with Black + run: | + black $(git ls-files '*.py') + - name: Add and commit + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "noreply@github.com" + git add * + git commit -m "Format \"$(git log -1 --pretty=%s)\" using Black" diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 766c044..dfaab50 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -22,6 +22,6 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt pip install -r requirements_dev.txt - - name: Analysing the code with pylint + - name: Analysing the code with Pylint run: | pylint $(git ls-files '*.py') diff --git a/pyproject.toml b/pyproject.toml index 5ddff4f..9f6e61d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ dependencies = [ ] # Lock file: requirements_dev.txt optional-dependencies.dev = [ + "black == 24.8.0", "pylint == 3.2.6", "pytest == 8.3.2", ] diff --git a/requirements_dev.txt b/requirements_dev.txt index 220e79a..391a504 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,10 +1,14 @@ astroid == 3.2.4 +black == 24.8.0 +click == 8.1.7 colorama == 0.4.6 dill == 0.3.8 iniconfig == 2.0.0 isort == 5.13.2 mccabe == 0.7.0 +mypy-extensions == 1.0.0 packaging == 24.1 +pathspec == 0.12.1 platformdirs == 4.2.2 pluggy == 1.5.0 pylint == 3.2.6