From b9d1e72fe1c7cc7be88aa2f3f45bc62bce633ae6 Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Thu, 26 Dec 2024 10:40:19 +1100 Subject: [PATCH 1/4] Add Ruff formatting action --- .github/workflows/ruff.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ruff.yml diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 00000000..f807cfaf --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,23 @@ +name: Ruff Formatting +on: [pull_request] +jobs: + ruff: + if: ${{ github.actor != 'dependabot[bot]' }} # Do not run on commits created by dependabot + runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the changed files. + contents: write # Allows reading and writing repository contents (e.g., commits) + pull-requests: write # Allows reading and writing pull requests + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + token: ${{ secrets.GITHUB_TOKEN }} + - uses: chartboost/ruff-action@v1 + with: + src: './jcvi ./tests' + args: 'format --target-version py310' + - uses: stefanzweifel/git-auto-commit-action@v5 + id: auto-commit-action + with: + commit_message: 'Style fixes by Ruff' \ No newline at end of file From 5c9ce0ba4cadabdc954868fd9d02cc43284599e1 Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Thu, 26 Dec 2024 10:57:52 +1100 Subject: [PATCH 2/4] Use Black instead --- .github/workflows/{ruff.yml => Black.yml} | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) rename .github/workflows/{ruff.yml => Black.yml} (77%) diff --git a/.github/workflows/ruff.yml b/.github/workflows/Black.yml similarity index 77% rename from .github/workflows/ruff.yml rename to .github/workflows/Black.yml index f807cfaf..0d589ba6 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/Black.yml @@ -1,7 +1,7 @@ -name: Ruff Formatting +name: Black Formatting on: [pull_request] jobs: - ruff: + black: if: ${{ github.actor != 'dependabot[bot]' }} # Do not run on commits created by dependabot runs-on: ubuntu-latest permissions: @@ -13,11 +13,10 @@ jobs: with: ref: ${{ github.sha }} token: ${{ secrets.GITHUB_TOKEN }} - - uses: chartboost/ruff-action@v1 + - uses: psf/black@stable with: - src: './jcvi ./tests' - args: 'format --target-version py310' + path: "./jcvi ./tests" - uses: stefanzweifel/git-auto-commit-action@v5 id: auto-commit-action with: - commit_message: 'Style fixes by Ruff' \ No newline at end of file + commit_message: 'Style fixes by Black' \ No newline at end of file From 48eadc27c8a20f214efb44876d5be45a107a783a Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Thu, 26 Dec 2024 11:21:37 +1100 Subject: [PATCH 3/4] Don't use --check mode --- .github/workflows/Black.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Black.yml b/.github/workflows/Black.yml index 0d589ba6..18767f7b 100644 --- a/.github/workflows/Black.yml +++ b/.github/workflows/Black.yml @@ -13,10 +13,16 @@ jobs: with: ref: ${{ github.sha }} token: ${{ secrets.GITHUB_TOKEN }} - - uses: psf/black@stable + + - name: Black Code Formatter + uses: psf/black@stable with: - path: "./jcvi ./tests" - - uses: stefanzweifel/git-auto-commit-action@v5 + options: "--verbose" + src: "." + + - name: Commit changes + if: success() + uses: stefanzweifel/git-auto-commit-action@v5 id: auto-commit-action with: commit_message: 'Style fixes by Black' \ No newline at end of file From e8a1e9c1c40f2ec24708dc898d489420eb94a814 Mon Sep 17 00:00:00 2001 From: Adamtaranto Date: Thu, 26 Dec 2024 00:22:14 +0000 Subject: [PATCH 4/4] Style fixes by Black --- jcvi/formats/gff.py | 4 +--- tests/formats/test_bed.py | 1 + tests/formats/test_cblast_benchmark.py | 1 + tests/graphics/test_grabseeds.py | 2 +- tests/utils/test_range.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/jcvi/formats/gff.py b/jcvi/formats/gff.py index da13f3b6..6bd66def 100644 --- a/jcvi/formats/gff.py +++ b/jcvi/formats/gff.py @@ -2850,9 +2850,7 @@ def note(args): continue if AED is not None and float(g.attributes["_AED"][0]) > AED: continue - keyval = [g.accn] + [ - ",".join(g.attributes.get(x, ["nan"])) for x in attrib - ] + keyval = [g.accn] + [",".join(g.attributes.get(x, ["nan"])) for x in attrib] if exoncounts: nexons = exoncounts.get(g.accn, 0) keyval.append(str(nexons)) diff --git a/tests/formats/test_bed.py b/tests/formats/test_bed.py index dc742f62..9d10f194 100644 --- a/tests/formats/test_bed.py +++ b/tests/formats/test_bed.py @@ -3,6 +3,7 @@ from jcvi.formats.bed import summary + def test_summary(): cwd = os.getcwd() os.chdir(op.join(op.dirname(__file__), "data")) diff --git a/tests/formats/test_cblast_benchmark.py b/tests/formats/test_cblast_benchmark.py index 73161b90..c17dcdb0 100644 --- a/tests/formats/test_cblast_benchmark.py +++ b/tests/formats/test_cblast_benchmark.py @@ -5,6 +5,7 @@ import pytest import time + # Benchmark cblast vs blast module @pytest.mark.benchmark( group="CBlastLine vs PyBlastLine", timer=time.time, disable_gc=True, warmup=False diff --git a/tests/graphics/test_grabseeds.py b/tests/graphics/test_grabseeds.py index 432d2314..81b2c808 100644 --- a/tests/graphics/test_grabseeds.py +++ b/tests/graphics/test_grabseeds.py @@ -17,7 +17,7 @@ def test_main(): # Test calibrate json_file = "calibrate.json" cleanup(json_file, output_image) - json_file = calibrate(["calibrate.JPG", "1"]) # `1` for the boxsize arg + json_file = calibrate(["calibrate.JPG", "1"]) # `1` for the boxsize arg assert op.exists(json_file) seeds(["test.JPG", "--calibrate", json_file]) diff --git a/tests/utils/test_range.py b/tests/utils/test_range.py index cbb0008d..74808eaa 100644 --- a/tests/utils/test_range.py +++ b/tests/utils/test_range.py @@ -212,4 +212,4 @@ def test_range_conflict(ranges, expected): def test_range_chain(ranges, expected): from jcvi.utils.range import range_chain - assert range_chain(ranges) == expected \ No newline at end of file + assert range_chain(ranges) == expected