Skip to content

Commit e254fa7

Browse files
Use pre-commit for CI linting and update to latest tool versions
1 parent 6bcaaec commit e254fa7

File tree

6 files changed

+211
-420
lines changed

6 files changed

+211
-420
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -284,27 +284,14 @@ jobs:
284284
with:
285285
python-version: '3.10'
286286

287-
- name: Install quality tools
287+
- name: Install pre-commit
288288
run: |
289289
python -m pip install --upgrade pip
290-
pip install flake8 black==25.9.0 isort mypy
290+
pip install pre-commit
291291
pip install -e .
292292
293-
- name: Run Black
294-
run: black --check --diff src/spine/
295-
296-
- name: Run isort
297-
run: isort --check-only --diff src/spine/
298-
299-
- name: Run flake8
300-
run: |
301-
# Configure flake8 to focus on critical issues while allowing common library patterns
302-
# Ignoring: F401/F403/F405 (import patterns), F841 (unused vars), E501 (line length handled by Black)
303-
# E711/E712/E713 (comparison style), W391/W291/W293 (whitespace), E221/E265/E266 (spacing/comments)
304-
# F822/F601/F823 (name issues), E722 (bare except), others (library-specific patterns)
305-
flake8 src/spine/ \
306-
--max-line-length=88 \
307-
--extend-ignore=E203,W503,F401,F403,F405,W605,E731,E741,F811,F821,F541,F841,E501,W391,W291,W293,E221,E265,E266,F822,F601,F823,E722,E711,E712,E713
293+
- name: Run pre-commit checks
294+
run: pre-commit run --all-files --show-diff-on-failure
308295

309296
- name: Run mypy on critical modules
310297
run: |

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.6.0 # Updated to latest
7+
rev: v6.0.0 # Updated to latest
88
hooks:
99
- id: trailing-whitespace
1010
exclude: '\.md$' # Allow trailing spaces in Markdown
@@ -19,20 +19,20 @@ repos:
1919
- id: requirements-txt-fixer
2020

2121
- repo: https://github.com/psf/black
22-
rev: 24.8.0 # Updated to latest
22+
rev: 26.1.0 # Updated to latest
2323
hooks:
2424
- id: black
2525
language_version: python3
2626
args: [--line-length=88] # Explicit line length
2727

2828
- repo: https://github.com/pycqa/isort
29-
rev: 5.13.2 # Updated to latest
29+
rev: 7.0.0 # Updated to latest
3030
hooks:
3131
- id: isort
3232
args: [--profile=black, --line-length=88] # Match Black config
3333

3434
- repo: https://github.com/pycqa/flake8
35-
rev: 7.1.1 # Updated to latest
35+
rev: 7.3.0 # Updated to latest
3636
hooks:
3737
- id: flake8
3838
# Use same ignore list as CI for consistency

src/spine/model/experimental/layer/pointnet.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,17 @@ def __init__(self, cfg, name="pointnet"):
5757
elif isinstance(self.sampling_ratio, list):
5858
assert len(self.sampling_ratio) == self.depth
5959
else:
60-
raise ValueError(
61-
"Sampling ratio must either be given as \
62-
float or list of floats."
63-
)
60+
raise ValueError("Sampling ratio must either be given as \
61+
float or list of floats.")
6462

6563
self.neighbor_radius = self.model_config.get("neighbor_radius", 3.0)
6664
if isinstance(self.neighbor_radius, float):
6765
self.neighbor_radius = [self.neighbor_radius] * self.depth
6866
elif isinstance(self.neighbor_radius, list):
6967
assert len(self.neighbor_radius) == self.depth
7068
else:
71-
raise ValueError(
72-
"Neighbor aggregation radius must either \
73-
be given as float or list of floats."
74-
)
69+
raise ValueError("Neighbor aggregation radius must either \
70+
be given as float or list of floats.")
7571

7672
self.mlp_specs = []
7773
self.sa_modules = nn.ModuleList()

src/spine/model/full_chain.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ def run_part_aggregation(self, data, clust_label=None, coord_label=None):
711711
# Use GraPA to aggregate instances
712712
prefix = f"{name}_fragment" if name != "particle" else "fragment"
713713
model = getattr(self, f"grappa_{name}")
714-
(groups, group_shapes, group_primaries, shape_index) = self.run_grappa(
714+
groups, group_shapes, group_primaries, shape_index = self.run_grappa(
715715
prefix,
716716
model,
717717
data,
@@ -738,16 +738,14 @@ def run_part_aggregation(self, data, clust_label=None, coord_label=None):
738738

739739
elif switch == "label":
740740
# Use cluster labels to aggregate instances
741-
(groups, group_shapes, group_primaries, shape_index) = (
742-
self.group_labels(
743-
shapes[name],
744-
data,
745-
fragments,
746-
fragment_shapes,
747-
aggregate_shapes=True,
748-
shape_use_primary=use_primary[name],
749-
retain_primaries=use_primary[name],
750-
)
741+
groups, group_shapes, group_primaries, shape_index = self.group_labels(
742+
shapes[name],
743+
data,
744+
fragments,
745+
fragment_shapes,
746+
aggregate_shapes=True,
747+
shape_use_primary=use_primary[name],
748+
retain_primaries=use_primary[name],
751749
)
752750

753751
elif switch == "skip":

src/spine/model/layer/cnn/blocks.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,8 @@ def __init__(
568568
elif mode == "sum":
569569
self.pool_fn = ME.MinkowskiSumPooling
570570
else:
571-
raise ValueError(
572-
"Invalid pooling mode, must be one of \
573-
'sum', 'max' or 'average'"
574-
)
571+
raise ValueError("Invalid pooling mode, must be one of \
572+
'sum', 'max' or 'average'")
575573

576574
self.unpool_fn = ME.MinkowskiPoolingTranspose
577575

0 commit comments

Comments
 (0)