Skip to content

Commit bf7925b

Browse files
authored
Merge pull request #25 from dronefreak/claude/fix-ci-code-quality-YYeqX
fix: CI code quality checks and remove duplicate README
2 parents 93f40d4 + 15ffbd3 commit bf7925b

16 files changed

Lines changed: 133 additions & 316 deletions

File tree

.github/README.md

Lines changed: 0 additions & 116 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
run: twine check dist/*
163163

164164
- name: Upload build artifacts
165-
uses: actions/upload-artifact@v3
165+
uses: actions/upload-artifact@v4
166166
with:
167167
name: dist-packages
168168
path: dist/

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 45 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,70 @@
1-
# Pre-commit hooks for CABiNet project
2-
# Note: pre-commit will ignore anything that is already ignored by Git.
1+
# Pre-commit hooks configuration
2+
# See https://pre-commit.com for more information
33

44
default_language_version:
5-
python: python3.10
5+
python: python3
66

77
repos:
8-
# Python code formatting
9-
- repo: https://github.com/psf/black
10-
rev: 25.1.0
8+
# ---------- BASIC SANITY ----------
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v6.0.0
1111
hooks:
12-
- id: black
13-
language_version: python3
14-
args: [--line-length=100]
15-
exclude: ^(legacy/|.*\.ipynb)
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: check-yaml
15+
- id: check-toml
16+
- id: check-json
17+
- id: check-added-large-files
18+
args: [--maxkb=5000]
19+
- id: check-ast
20+
- id: debug-statements
21+
- id: check-merge-conflict
22+
- id: detect-private-key
1623

17-
# Import sorting
18-
- repo: https://github.com/pycqa/isort
19-
rev: 5.13.2
24+
# ---------- PYTHON FORMAT ----------
25+
- repo: https://github.com/psf/black
26+
rev: 25.12.0
2027
hooks:
21-
- id: isort
22-
language_version: python3
23-
args: [--profile=black, --line-length=100]
24-
exclude: ^(legacy/|.*\.ipynb)
28+
- id: black
29+
args: [--line-length=88]
2530

26-
# Linting
27-
- repo: https://github.com/pycqa/flake8
28-
rev: 7.3.0
31+
# ---------- PYTHON LINT (NO FIX) ----------
32+
- repo: https://github.com/astral-sh/ruff-pre-commit
33+
rev: v0.14.10
2934
hooks:
30-
- id: flake8
31-
language_version: python3
32-
additional_dependencies: [
33-
"flake8-docstrings",
34-
"flake8-bugbear",
35-
"flake8-comprehensions",
36-
"pep8-naming",
37-
]
38-
args: [--max-line-length=100, --extend-ignore=E203,W503]
39-
exclude: ^(legacy/|tests/|.*\.ipynb)
35+
- id: ruff
36+
args: [--fix]
37+
types_or: [python, pyi]
4038

41-
# Type checking
39+
# ---------- TYPES ----------
4240
- repo: https://github.com/pre-commit/mirrors-mypy
43-
rev: v1.14.0
41+
rev: v1.19.1
4442
hooks:
4543
- id: mypy
46-
language_version: python3
47-
additional_dependencies: [types-all]
4844
args: [--ignore-missing-imports, --check-untyped-defs]
49-
exclude: ^(tests/|legacy/|.*\.ipynb)
45+
additional_dependencies:
46+
- types-PyYAML
47+
- types-requests
48+
files: ^src/
5049

51-
# Security checks
50+
# ---------- SECURITY ----------
5251
- repo: https://github.com/PyCQA/bandit
53-
rev: 1.8.0
52+
rev: 1.9.2
5453
hooks:
5554
- id: bandit
56-
args: [-ll, -r, src/]
57-
exclude: ^(tests/|legacy/)
55+
args: [-c, pyproject.toml, -r, src/]
56+
additional_dependencies: ["bandit[toml]"]
5857

59-
# Standard pre-commit hooks
60-
- repo: https://github.com/pre-commit/pre-commit-hooks
61-
rev: v5.0.0
62-
hooks:
63-
- id: check-added-large-files
64-
args: [--maxkb=1000] # Increased for model weights
65-
- id: check-ast # Validate Python syntax
66-
- id: check-builtin-literals # Require literal syntax
67-
- id: check-case-conflict # Check for files with case conflicts
68-
- id: check-docstring-first # Ensure docstring before code
69-
- id: check-executables-have-shebangs
70-
- id: check-json
71-
- id: check-merge-conflict
72-
- id: check-symlinks
73-
- id: check-toml
74-
- id: check-yaml
75-
args: [--unsafe] # Allow custom YAML tags
76-
- id: debug-statements # Check for debugger imports
77-
- id: detect-private-key # Detect private keys
78-
- id: end-of-file-fixer # Ensure files end with newline
79-
- id: mixed-line-ending # Fix mixed line endings
80-
args: [--fix=lf]
81-
- id: trailing-whitespace # Remove trailing whitespace
82-
args: [--markdown-linebreak-ext=md]
83-
84-
# Docstring formatting
85-
- repo: https://github.com/PyCQA/docformatter
86-
rev: v1.7.7
87-
hooks:
88-
- id: docformatter
89-
args: [
90-
--in-place,
91-
--wrap-summaries=100,
92-
--wrap-descriptions=100,
93-
--make-summary-multi-line,
94-
]
95-
exclude: ^(legacy/|.*\.ipynb)
96-
97-
# Upgrade Python syntax
98-
- repo: https://github.com/asottile/pyupgrade
99-
rev: v3.19.1
100-
hooks:
101-
- id: pyupgrade
102-
args: [--py38-plus]
103-
exclude: ^(legacy/|.*\.ipynb)
104-
105-
# YAML/JSON/TOML formatting
58+
# ---------- NON-PYTHON FORMAT ----------
10659
- repo: https://github.com/pre-commit/mirrors-prettier
10760
rev: v4.0.0-alpha.8
10861
hooks:
10962
- id: prettier
110-
types_or: [yaml, json, toml, markdown]
111-
exclude: ^(legacy/)
63+
types_or: [yaml, markdown, json]
11264

113-
# Jupyter notebook cleaning (optional)
114-
- repo: https://github.com/kynan/nbstripout
115-
rev: 0.8.1
65+
# ---------- COMMIT MSG ----------
66+
- repo: https://github.com/compilerla/conventional-pre-commit
67+
rev: v4.3.0
11668
hooks:
117-
- id: nbstripout
118-
description: Strip output from Jupyter notebooks
119-
120-
# Check for TODO/FIXME comments (warning only)
121-
- repo: https://github.com/pre-commit/mirrors-pylint
122-
rev: v2.7.4
123-
hooks:
124-
- id: pylint
125-
args: [
126-
--disable=all,
127-
--enable=fixme,
128-
--notes=TODO,FIXME,XXX,
129-
]
130-
exclude: ^(tests/|legacy/)
131-
stages: [manual] # Only run when explicitly called
132-
133-
# Configuration for specific hooks
134-
ci:
135-
autofix_commit_msg: |
136-
[pre-commit.ci] auto fixes from pre-commit hooks
137-
autofix_prs: true
138-
autoupdate_branch: ''
139-
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
140-
autoupdate_schedule: weekly
141-
skip: [pylint] # Skip slow hooks in CI
142-
submodules: false
69+
- id: conventional-pre-commit
70+
stages: [commit-msg]

src/datasets/transform.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"""
1111

1212
import random
13-
from typing import Dict, Tuple, Optional
1413

1514
from PIL import Image, ImageEnhance
1615
import numpy as np

src/models/cab.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ def __init__(self, channels, stride=1):
2222
super().__init__()
2323
self.block = nn.Sequential(
2424
nn.Conv2d(
25-
channels, channels, kernel_size=3, stride=stride, padding=1,
26-
groups=channels, bias=False
25+
channels,
26+
channels,
27+
kernel_size=3,
28+
stride=stride,
29+
padding=1,
30+
groups=channels,
31+
bias=False,
2732
),
2833
nn.BatchNorm2d(channels),
2934
nn.ReLU(inplace=True),
@@ -48,9 +53,7 @@ class PSPModule(nn.Module):
4853

4954
def __init__(self, in_channels, sizes=(1, 3, 6, 8)):
5055
super().__init__()
51-
self.stages = nn.ModuleList([
52-
nn.AdaptiveAvgPool2d((s, s)) for s in sizes
53-
])
56+
self.stages = nn.ModuleList([nn.AdaptiveAvgPool2d((s, s)) for s in sizes])
5457

5558
self.project = nn.Conv2d(
5659
in_channels * (len(sizes) + 1), # +1 for identity
@@ -98,9 +101,7 @@ def __init__(
98101
self.out_channels = out_channels or in_channels
99102

100103
# Optional spatial reduction
101-
self.pool = (
102-
nn.MaxPool2d(kernel_size=scale) if scale > 1 else nn.Identity()
103-
)
104+
self.pool = nn.MaxPool2d(kernel_size=scale) if scale > 1 else nn.Identity()
104105

105106
# Query / Key / Value projections
106107
self.to_query = nn.Sequential(

0 commit comments

Comments
 (0)