Skip to content

Commit ae16201

Browse files
authored
Merge pull request #24 from richardkoehler/feat/format-code
feat: format code
2 parents ee1829c + a3d7281 commit ae16201

46 files changed

Lines changed: 2125 additions & 1631 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/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
run: |
3232
uv run ruff check --exclude tests .
3333
34+
- name: Run ruff format (check)
35+
run: |
36+
uv run ruff format --check --exclude tests .
37+
3438
# Tests are temporarily disabled in CI until they are ready.
3539
# To re-enable, uncomment the step below once tests are stable.
3640
# - name: Run pytest

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
repos:
2+
- repo: https://github.com/astral-sh/uv-pre-commit
3+
rev: 0.11.5
4+
hooks:
5+
- id: uv-lock
6+
27
- repo: https://github.com/astral-sh/ruff-pre-commit
38
rev: v0.15.9
49
hooks:
10+
- id: ruff-format
511
- id: ruff-check
612
args: ["--fix", "--exclude", "tests"]

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "clinical-dbs-annotator"
33
description = "A graphical user interface for annotating DBS clinical programming sessions"
44
readme = "README.md"
5-
requires-python = ">=3.11"
5+
requires-python = ">=3.14"
66
authors = [
77
{ name = "Lucia Poma", email = "lucia.poma@wysscenter.ch" }
88
]
@@ -14,9 +14,6 @@ classifiers = [
1414
"Intended Audience :: Science/Research",
1515
"Topic :: Scientific/Engineering :: Medical Science Apps.",
1616
"Programming Language :: Python :: 3",
17-
"Programming Language :: Python :: 3.11",
18-
"Programming Language :: Python :: 3.12",
19-
"Programming Language :: Python :: 3.13",
2017
"Programming Language :: Python :: 3.14",
2118
"License :: OSI Approved :: MIT License",
2219
"Environment :: X11 Applications :: Qt",

scripts/build_macos.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
APP_NAME = "ClinicalDBSAnnot"
2222
PLATFORM = "macOS"
2323

24+
2425
def _read_version() -> str:
2526
init_path = SRC_DIR / "clinical_dbs_annotator" / "__init__.py"
2627
text = init_path.read_text(encoding="utf-8")
27-
m = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']\s*$', text, flags=re.MULTILINE)
28+
m = re.search(
29+
r'^__version__\s*=\s*["\']([^"\']+)["\']\s*$', text, flags=re.MULTILINE
30+
)
2831
if not m:
2932
raise RuntimeError(f"Could not determine version from {init_path}")
3033
return m.group(1)
@@ -141,8 +144,14 @@ def build_macos_app(*, console: bool, onefile: bool):
141144
def main():
142145
"""Main entry point."""
143146
parser = argparse.ArgumentParser()
144-
parser.add_argument("--console", action="store_true", help="Build with console window")
145-
parser.add_argument("--onedir", action="store_true", help="Build as a folder (onedir) instead of a single bundle (onefile)")
147+
parser.add_argument(
148+
"--console", action="store_true", help="Build with console window"
149+
)
150+
parser.add_argument(
151+
"--onedir",
152+
action="store_true",
153+
help="Build as a folder (onedir) instead of a single bundle (onefile)",
154+
)
146155
parser.add_argument(
147156
"--mac-logo-png",
148157
type=Path,

scripts/build_quick.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
PROJECT_ROOT = Path(__file__).resolve().parent.parent
1616

17+
1718
def run_command(cmd, cwd=None):
1819
"""Run a command and handle errors."""
1920
print(f"Running: {' '.join(cmd)}")
@@ -24,6 +25,7 @@ def run_command(cmd, cwd=None):
2425
print(f"❌ Failed with exit code {e.returncode}")
2526
sys.exit(1)
2627

28+
2729
if __name__ == "__main__":
2830
if len(sys.argv) < 2:
2931
print("Usage: python scripts/build_quick.py <target>")

scripts/build_windows.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
APP_NAME = "ClinicalDBSAnnotator"
2020
PLATFORM = "Windows"
2121

22+
2223
def _read_version() -> str:
2324
init_path = SRC_DIR / "clinical_dbs_annotator" / "__init__.py"
2425
text = init_path.read_text(encoding="utf-8")
25-
m = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']\s*$', text, flags=re.MULTILINE)
26+
m = re.search(
27+
r'^__version__\s*=\s*["\']([^"\']+)["\']\s*$', text, flags=re.MULTILINE
28+
)
2629
if not m:
2730
raise RuntimeError(f"Could not determine version from {init_path}")
2831
return m.group(1)
@@ -41,7 +44,9 @@ def build_windows_exe(*, console: bool, onefile: bool) -> bool:
4144
config_dir = SRC_DIR / "clinical_dbs_annotator" / "config"
4245

4346
cmd = [
44-
sys.executable, "-m", "PyInstaller",
47+
sys.executable,
48+
"-m",
49+
"PyInstaller",
4550
"--noconfirm",
4651
"--clean",
4752
f"--name={name}",
@@ -97,8 +102,14 @@ def build_windows_exe(*, console: bool, onefile: bool) -> bool:
97102
def main():
98103
"""Main entry point."""
99104
parser = argparse.ArgumentParser()
100-
parser.add_argument("--console", action="store_true", help="Build with console window")
101-
parser.add_argument("--onedir", action="store_true", help="Build as a folder (onedir) instead of a single exe (onefile)")
105+
parser.add_argument(
106+
"--console", action="store_true", help="Build with console window"
107+
)
108+
parser.add_argument(
109+
"--onedir",
110+
action="store_true",
111+
help="Build as a folder (onedir) instead of a single exe (onefile)",
112+
)
102113
args = parser.parse_args()
103114

104115
if not (ICONS_DIR / "logoneutral.ico").exists():

scripts/build_windows_nuitka.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@
3030
NAME = "ClinicalDBSAnnotator"
3131
ENTRYPOINT = PROJECT_ROOT / "run.py"
3232

33+
3334
def _read_version() -> str:
3435
init_path = SRC_DIR / "clinical_dbs_annotator" / "__init__.py"
3536
text = init_path.read_text(encoding="utf-8")
36-
m = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']\s*$', text, flags=re.MULTILINE)
37+
m = re.search(
38+
r'^__version__\s*=\s*["\']([^"\']+)["\']\s*$', text, flags=re.MULTILINE
39+
)
3740
if not m:
3841
raise RuntimeError(f"Could not determine version from {init_path}")
3942
return m.group(1)
@@ -80,6 +83,7 @@ def _base_version(version: str) -> str:
8083
"imageformats",
8184
]
8285

86+
8387
def build_nuitka(console: bool = False, onefile: bool = False) -> None:
8488
"""Build the executable with Nuitka."""
8589
DIST_DIR.mkdir(exist_ok=True)
@@ -118,20 +122,24 @@ def build_nuitka(console: bool = False, onefile: bool = False) -> None:
118122

119123
cmd.append("--follow-imports")
120124

121-
cmd.extend([
122-
"--enable-plugin=pyside6",
123-
])
125+
cmd.extend(
126+
[
127+
"--enable-plugin=pyside6",
128+
]
129+
)
124130

125131
icon_path = ICONS_DIR / "logoneutral.ico"
126132
if icon_path.exists():
127133
cmd.append(f"--windows-icon-from-ico={icon_path}")
128134

129-
cmd.extend([
130-
"--windows-company-name=Brain Modulation Lab",
131-
"--windows-product-name=Clinical DBS Annotator",
132-
f"--windows-file-version={BASE_VERSION}",
133-
f"--windows-product-version={BASE_VERSION}",
134-
])
135+
cmd.extend(
136+
[
137+
"--windows-company-name=Brain Modulation Lab",
138+
"--windows-product-name=Clinical DBS Annotator",
139+
f"--windows-file-version={BASE_VERSION}",
140+
f"--windows-product-version={BASE_VERSION}",
141+
]
142+
)
135143

136144
cmd.append(str(ENTRYPOINT))
137145

@@ -141,6 +149,7 @@ def build_nuitka(console: bool = False, onefile: bool = False) -> None:
141149

142150
try:
143151
import subprocess
152+
144153
subprocess.run(cmd, check=True, cwd=PROJECT_ROOT)
145154
print("\n✅ Build completed successfully!")
146155

@@ -151,7 +160,7 @@ def build_nuitka(console: bool = False, onefile: bool = False) -> None:
151160

152161
if exe_path.exists():
153162
print(f"📦 Executable: {exe_path}")
154-
print(f"📊 Size: {exe_path.stat().st_size / (1024*1024):.1f} MB")
163+
print(f"📊 Size: {exe_path.stat().st_size / (1024 * 1024):.1f} MB")
155164
else:
156165
print("⚠️ Executable not found at expected location")
157166

@@ -162,12 +171,19 @@ def build_nuitka(console: bool = False, onefile: bool = False) -> None:
162171
print("\n❌ Nuitka not found. Install it with: pip install nuitka")
163172
sys.exit(1)
164173

174+
165175
if __name__ == "__main__":
166176
parser = argparse.ArgumentParser(description="Build Windows executable with Nuitka")
167-
parser.add_argument("--console", action="store_true",
168-
help="Include console window (useful for debugging)")
169-
parser.add_argument("--onefile", action="store_true",
170-
help="Create single .exe file (default: directory bundle)")
177+
parser.add_argument(
178+
"--console",
179+
action="store_true",
180+
help="Include console window (useful for debugging)",
181+
)
182+
parser.add_argument(
183+
"--onefile",
184+
action="store_true",
185+
help="Create single .exe file (default: directory bundle)",
186+
)
171187

172188
args = parser.parse_args()
173189

src/clinical_dbs_annotator/config.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
# Responsive window size ratios based on screen size
2929
RESPONSIVE_WINDOW_RATIOS = {
30-
"small": {"width": 0.9, "height": 0.85}, # < 1400px width
31-
"medium": {"width": 0.85, "height": 0.8}, # 1400-1919px width
30+
"small": {"width": 0.9, "height": 0.85}, # < 1400px width
31+
"medium": {"width": 0.85, "height": 0.8}, # 1400-1919px width
3232
"large": {"width": 0.75, "height": 0.75}, # >= 1920px width
3333
}
3434

@@ -99,33 +99,34 @@
9999

100100
CLINICAL_SCALES_PRESETS: dict[str, list[str]] = {
101101
"OCD": [
102-
"Y-BOCS", # Yale–Brown Obsessive–Compulsive Scale
103-
"Y-BOCS-o", "Y-BOCS-c",
104-
"MADRS", # Montgomery–Åsberg Depression Rating Scale
105-
"OCI-R", # Obsessive–Compulsive Inventory – Revised
102+
"Y-BOCS", # Yale–Brown Obsessive–Compulsive Scale
103+
"Y-BOCS-o",
104+
"Y-BOCS-c",
105+
"MADRS", # Montgomery–Åsberg Depression Rating Scale
106+
"OCI-R", # Obsessive–Compulsive Inventory – Revised
106107
],
107108
"MDD": [
108-
"MADRS", # Montgomery–Åsberg Depression Rating Scale
109-
"HAM-D", # Hamilton Depression Rating Scale
110-
"BDI-II", # Beck Depression Inventory – Second Edition
109+
"MADRS", # Montgomery–Åsberg Depression Rating Scale
110+
"HAM-D", # Hamilton Depression Rating Scale
111+
"BDI-II", # Beck Depression Inventory – Second Edition
111112
],
112113
"PD": [
113114
"MDS-UPDRS", # Movement Disorder Society – Unified Parkinson’s Disease Rating Scale
114115
"UPDRS-III", # Unified Parkinson’s Disease Rating Scale part III
115-
"PDQ-39", # Parkinson’s Disease Questionnaire (39-item)
116-
"UDysRS", # Unified Dyskinesia Rating Scale
116+
"PDQ-39", # Parkinson’s Disease Questionnaire (39-item)
117+
"UDysRS", # Unified Dyskinesia Rating Scale
117118
],
118119
"ET": [
119120
"FTM-TRS", # Fahn–Tolosa–Marin Tremor Rating Scale
120-
"TETRAS", # The Essential Tremor Rating Assessment Scale
121+
"TETRAS", # The Essential Tremor Rating Assessment Scale
121122
],
122123
"Dystonia": [
123124
"BFMDRS", # Burke–Fahn–Marsden Dystonia Rating Scale
124125
"TWSTRS", # Toronto Western Spasmodic Torticollis Rating Scale
125126
],
126127
"TS": [
127-
"YGTSS", # Yale Global Tic Severity Scale
128-
"PUTS", # Premonitory Urge for Tics Scale
128+
"YGTSS", # Yale Global Tic Severity Scale
129+
"PUTS", # Premonitory Urge for Tics Scale
129130
"TS-CGI", # Tourette Syndrome Clinical Global Impression
130131
"Y-BOCS", # Yale–Brown Obsessive–Compulsive Scale
131132
],

0 commit comments

Comments
 (0)