Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Black formatting action #734

Merged
merged 4 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/Black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Black Formatting
on: [pull_request]
jobs:
black:
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 }}

- name: Black Code Formatter
uses: psf/black@stable
with:
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'
4 changes: 1 addition & 3 deletions jcvi/formats/gff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions tests/formats/test_bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from jcvi.formats.bed import summary


def test_summary():
cwd = os.getcwd()
os.chdir(op.join(op.dirname(__file__), "data"))
Expand Down
1 change: 1 addition & 0 deletions tests/formats/test_cblast_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/graphics/test_grabseeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
assert range_chain(ranges) == expected