Skip to content

Commit 850eff9

Browse files
authored
Merge pull request #12 from richardkoehler/feature/lint
Update python and lint codebase
2 parents 61ed42d + 02b80f0 commit 850eff9

26 files changed

Lines changed: 346 additions & 92 deletions

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.11.15
1+
3.14

pyproject.toml

Lines changed: 3 additions & 2 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,<3.14"
5+
requires-python = ">=3.11"
66
authors = [
77
{ name = "Lucia Poma", email = "lucia.poma@wysscenter.ch" }
88
]
@@ -17,6 +17,7 @@ classifiers = [
1717
"Programming Language :: Python :: 3.11",
1818
"Programming Language :: Python :: 3.12",
1919
"Programming Language :: Python :: 3.13",
20+
"Programming Language :: Python :: 3.14",
2021
"License :: OSI Approved :: MIT License",
2122
"Environment :: X11 Applications :: Qt",
2223
"Operating System :: OS Independent",
@@ -82,7 +83,7 @@ addopts = [
8283

8384
[tool.ruff]
8485
line-length = 88
85-
target-version = "py311"
86+
target-version = "py314"
8687
extend-exclude = [
8788
".eggs",
8889
".git",

run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from Visual Studio or any IDE.
66
77
Usage:
8-
python run.py
8+
python run.py
99
"""
1010

1111
import sys

scripts/build_windows_nuitka.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def build_nuitka(console: bool = False, onefile: bool = False) -> None:
140140
# Execute
141141
try:
142142
import subprocess
143-
result = subprocess.run(cmd, check=True, cwd=PROJECT_ROOT)
143+
subprocess.run(cmd, check=True, cwd=PROJECT_ROOT)
144144
print("\n✅ Build completed successfully!")
145145

146146
# Show output location

src/clinical_dbs_annotator/config_electrode_models.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ def add_validator(validator_fn):
2626
def validate_configuration(contact_states, case_state):
2727
"""
2828
Validate stimulation configuration according to clinical rules
29-
29+
3030
Args:
3131
contact_states (dict): Dictionary of {(contact_idx, segment_idx): ContactState}
3232
case_state (ContactState): State of the case
33-
33+
3434
Returns:
3535
tuple: (is_valid, error_message)
3636
"""
@@ -73,11 +73,11 @@ def validate_configuration(contact_states, case_state):
7373
def get_suggested_fix(contact_states, case_state):
7474
"""
7575
Suggest a fix for invalid configuration
76-
76+
7777
Args:
7878
contact_states (dict): Dictionary of contact states
7979
case_state (ContactState): State of the case
80-
80+
8181
Returns:
8282
str: Suggestion message
8383
"""
@@ -410,10 +410,10 @@ def is_level_directional(self, level_idx):
410410
def get_model_by_name(name):
411411
"""
412412
Get electrode model by name
413-
413+
414414
Args:
415415
name (str): Model name
416-
416+
417417
Returns:
418418
ElectrodeModel: Electrode model object or None if not found
419419
"""
@@ -423,7 +423,7 @@ def get_model_by_name(name):
423423
def get_all_model_names():
424424
"""
425425
Get list of all electrode model names
426-
426+
427427
Returns:
428428
list: List of model names
429429
"""
@@ -433,10 +433,10 @@ def get_all_model_names():
433433
def get_models_by_manufacturer(manufacturer):
434434
"""
435435
Get list of models for a specific manufacturer
436-
436+
437437
Args:
438438
manufacturer (str): Manufacturer name
439-
439+
440440
Returns:
441441
list: List of model names for the manufacturer
442442
"""
@@ -446,7 +446,7 @@ def get_models_by_manufacturer(manufacturer):
446446
def get_all_manufacturers():
447447
"""
448448
Get list of all manufacturers
449-
449+
450450
Returns:
451451
list: List of manufacturer names
452452
"""

src/clinical_dbs_annotator/controllers/wizard_controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def close_session(self, parent) -> None:
422422
def export_session_word(self, parent, scale_prefs=None, sections=None) -> None:
423423
"""
424424
Export current session data to Word format.
425-
425+
426426
Args:
427427
parent: The parent widget for dialogs
428428
scale_prefs: Scale optimization prefs from the dialog
@@ -434,7 +434,7 @@ def export_session_word(self, parent, scale_prefs=None, sections=None) -> None:
434434
def export_session_pdf(self, parent, scale_prefs=None, sections=None) -> None:
435435
"""
436436
Export current session data to PDF format.
437-
437+
438438
Args:
439439
parent: The parent widget for dialogs
440440
scale_prefs: Scale optimization prefs from the dialog

src/clinical_dbs_annotator/models/electrode_viewer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
Based on Lead-DBS repository models
66
"""
77

8+
import typing
9+
810
from PySide6.QtCore import QPointF, QRectF, Qt
911
from PySide6.QtGui import (
1012
QBrush,
@@ -188,7 +190,7 @@ def set_ring_state(self, ring_idx, state):
188190
new_states[contact_id] = state
189191

190192
self._apply_change_if_valid(new_states, self.case_state)
191-
193+
@typing.override
192194
def mousePressEvent(self, event):
193195
"""Handle clicks on contacts, rings and case"""
194196
if event.button() == Qt.LeftButton:
@@ -223,6 +225,7 @@ def mousePressEvent(self, event):
223225
self.cycle_case_state()
224226
return
225227

228+
@typing.override
226229
def mouseMoveEvent(self, event):
227230
"""Handle hover over contacts, rings and case"""
228231
old_hovered_contact = self.hovered_contact
@@ -260,6 +263,7 @@ def get_state_color(self, state, is_hovered=False):
260263

261264
return base_color, border_color, border_width
262265

266+
@typing.override
263267
def paintEvent(self, event):
264268
"""Render the electrode lead, contacts, case, and labels."""
265269
if not self.model:
@@ -336,7 +340,7 @@ def paintEvent(self, event):
336340
contact_height_px = self.model.contact_height * scale
337341
# E0 is the last contact (index 0), positioned after all other contacts and their spacing
338342
e0_y_position = start_y + 2 * scale # Initial offset
339-
for i in range(self.model.num_contacts - 1): # All contacts except E0
343+
for _ in range(self.model.num_contacts - 1): # All contacts except E0
340344
e0_y_position += contact_height_px + (self.model.contact_spacing + 1.0) * scale
341345

342346
# Lead body end position depends on electrode type
@@ -445,7 +449,7 @@ def paintEvent(self, event):
445449
self.ring_rects[contact_idx] = ring_cap_rect
446450

447451
# Directional electrode with 3D metallic segments
448-
segment_width = lead_width * 0.5
452+
lead_width * 0.5
449453
extension = base_extension
450454

451455
# Helper function to draw 3D segment
@@ -784,6 +788,7 @@ def draw_3d_segment(poly, state, is_hovered, contact_id, label):
784788
painter.drawText(ring_cap_rect, Qt.AlignCenter, "Ring")
785789

786790

791+
@typing.override
787792
def resizeEvent(self, event):
788793
"""Redraw when window is resized"""
789794
super().resizeEvent(event)

src/clinical_dbs_annotator/models/session_data.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,6 @@ def open_file_append(self, file_path: str, start_block_id: int | None = None) ->
130130
pass
131131
self.session_start_time = datetime.now()
132132

133-
def is_file_open(self) -> bool:
134-
"""
135-
Check if a TSV file is currently open.
136-
137-
Returns:
138-
True if file is open, False otherwise
139-
"""
140-
return self.tsv_file is not None and self.tsv_writer is not None
141133

142134
def close_file(self) -> None:
143135
"""Close the TSV file if it's open."""

src/clinical_dbs_annotator/models/stimulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def to_dict(self) -> dict:
5252
}
5353

5454
@classmethod
55-
def from_dict(cls, data: dict) -> "StimulationParameters":
55+
def from_dict(cls, data: dict) -> StimulationParameters:
5656
"""Create StimulationParameters from a dictionary."""
5757
return cls(
5858
left_frequency=data.get("left_stim_freq"),
@@ -67,7 +67,7 @@ def from_dict(cls, data: dict) -> "StimulationParameters":
6767
right_pulse_width=data.get("right_pulse_width"),
6868
)
6969

70-
def copy(self) -> "StimulationParameters":
70+
def copy(self) -> StimulationParameters:
7171
"""Create a copy of the stimulation parameters."""
7272
return StimulationParameters(
7373
left_frequency=self.left_frequency,

src/clinical_dbs_annotator/ui/amplitude_split_widget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def _refresh_ma_values(self) -> None:
277277

278278
def update_main_amplitude_from_split(self, split_text: str) -> None:
279279
"""Update the main amplitude field to show the sum of split values.
280-
280+
281281
When loading a file with split amplitude (e.g., "2.5_2.5"),
282282
this method calculates the sum and updates the main field.
283283
"""
@@ -297,7 +297,7 @@ def update_main_amplitude_from_split(self, split_text: str) -> None:
297297

298298
def set_amplitude_from_split(self, split_text: str) -> None:
299299
"""Set amplitude from split values and update percentages.
300-
300+
301301
When loading a file with split amplitude (e.g., "2.5_2.5"),
302302
this method:
303303
1. Updates the main amplitude field to show the sum

0 commit comments

Comments
 (0)