Skip to content

Commit daff97d

Browse files
committed
ci: add Ruff config, pre-commit hooks, and GitHub Actions lint workflow
- Add Ruff config (E/F/I rules, per-file ignores for __init__.py) - Add .pre-commit-config.yaml with ruff lint + format hooks - Add .github/workflows/lint.yml triggering on PRs - Auto-fix 63 violations (unsorted imports, unused imports, f-strings) Note: ruff-format is excluded from pre-commit and CI — this repo uses pyink. F722/F821 ignored: false positives from jaxtyping annotations.
1 parent 4dd4522 commit daff97d

45 files changed

Lines changed: 214 additions & 187 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: astral-sh/setup-uv@v5
14+
- run: uv python install 3.10
15+
- run: uv pip install ruff
16+
- run: uv run ruff check .

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.12.2
4+
hooks:
5+
- id: ruff
6+
args: [--fix]

hatch_build.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
import os
1818
from typing import Any
19-
from grpc_tools import protoc
20-
from hatchling.builders.hooks.plugin.interface import BuildHookInterface # pylint: disable=g-importing-member
2119

20+
from grpc_tools import protoc
21+
from hatchling.builders.hooks.plugin.interface import (
22+
BuildHookInterface, # pylint: disable=g-importing-member
23+
)
2224

2325
_ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'src')
2426

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,16 @@ unstable = true
134134
pyink-indentation = 2
135135
pyink-use-majority-quotes = true
136136
exclude = 'src/alphagenome/protos'
137+
138+
[tool.ruff]
139+
line-length = 80
140+
indent-width = 2
141+
extend-exclude = ["*.ipynb"]
142+
143+
[tool.ruff.lint]
144+
select = ["E", "F", "I"]
145+
# F722/F821: false positives from jaxtyping annotations
146+
ignore = ["E501", "E402", "E731", "E722", "E741", "E721", "E701", "F841", "F403", "F405", "F722", "F821"]
147+
148+
[tool.ruff.lint.per-file-ignores]
149+
"__init__.py" = ["F401"]

scripts/process_gtf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@
1616

1717
import os
1818
import tempfile
19-
from urllib import parse
20-
from urllib import request
19+
from urllib import parse, request
2120

22-
from absl import app
23-
from absl import flags
24-
from absl import logging
25-
from alphagenome.data import transcript as transcript_utils
2621
import pandas as pd
2722
import pyranges
23+
from absl import app, flags, logging
2824

25+
from alphagenome.data import transcript as transcript_utils
2926

3027
_GTF_PATH = flags.DEFINE_string(
3128
'gtf_path', None, 'Path to GTF file.', required=True

scripts/process_gtf_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from absl.testing import absltest
16-
from absl.testing import parameterized
1715
import numpy as np
1816
import pandas as pd
17+
from absl.testing import absltest, parameterized
1918

2019
from . import process_gtf
2120

22-
2321
_EXAMPLE_GTF = r"""
2422
chr1 FOO gene 12100 21316 . + . gene_id "GENE00000000001.1";
2523
chr1 FOO transcript 12100 18244 . + . gene_id "GENE00000000001.1"; transcript_id "TRANS00000000001.2";

src/alphagenome/colab_utils_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
from unittest import mock
1818

1919
from absl.testing import absltest
20-
from alphagenome import colab_utils
2120

21+
from alphagenome import colab_utils
2222

2323
_TEST_SECRET_KEY = '_TEST_ALPHAGENOME_API_KEY'
2424

src/alphagenome/data/fold_intervals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
import enum
1818

19-
from alphagenome.models import dna_client
2019
import immutabledict
2120
import pandas as pd
2221

22+
from alphagenome.models import dna_client
2323

2424
_DEFAULT_EXAMPLE_REGIONS = immutabledict.immutabledict({
2525
dna_client.Organism.HOMO_SAPIENS: (

src/alphagenome/data/fold_intervals_test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from absl.testing import absltest
16-
from absl.testing import parameterized
17-
from alphagenome.data import fold_intervals
18-
from alphagenome.models import dna_client
1915
import pandas as pd
16+
from absl.testing import absltest, parameterized
2017

18+
from alphagenome.data import fold_intervals
19+
from alphagenome.models import dna_client
2120

2221
_dummy_intervals = pd.DataFrame({
2322
'chromosome': ['chr' + str(i) for i in range(8)],

src/alphagenome/data/gene_annotation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414

1515
"""Utilities for working with gene annotations (e.g., GTFs)."""
1616

17-
from collections.abc import Sequence
1817
import enum
18+
from collections.abc import Sequence
1919

20-
from alphagenome.data import genome
2120
import numpy as np
2221
import pandas as pd
2322

23+
from alphagenome.data import genome
24+
2425

2526
@enum.unique
2627
class TranscriptType(enum.Enum):

0 commit comments

Comments
 (0)