fix: reduce complexity in scripts/predict.py to unblock xenon pre-commit - #281
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
raveriss
marked this pull request as ready for review
February 28, 2026 14:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
xenonà cause d'une complexité cyclomatique élevée dansscripts/predict.py::_build_npy_from_edf, il fallait simplifier la fonction sans modifier le comportement métier.Description
_ensure_physionet_files_exist(subject, run, raw_path, event_path)pour centraliser la validation des fichiers EDF/.edf.event et réduire les branches dans_build_npy_from_edf._summarize_epochs_with_missing_labels_fallback(epochs, motor_labels, subject, run)qui encapsule le fallback du QC (gestionValueError("Missing labels"))._build_npy_from_edf(...): il orchestre maintenant les helpers et contient moins de branches conditionnelles, ce qui réduit la complexité signalée par Xenon.test_ensure_physionet_files_exist_raises_when_event_missingdanstests/test_predict_load_data.pyet ajustement d’un test de diagnostic (tests/test_utils.py) pour accepter deux diagnostics valides selon l’environnement d’exécution.poetry.lock(bumppillow→12.1.1) pour résoudre un avertissement depip-auditgénéré durant la validation.scripts/predict.py,tests/test_predict_load_data.py,tests/test_utils.py,poetry.lock.Testing
poetry run pre-commit run --all-files --show-diff-on-failurethenpoetry run pre-commit run --all-files— hooks pass after minimal auto-reformat byblack(hook reformatted once, re-run OK).poetry run black --check .,poetry run isort --check-only .,poetry run ruff check .,poetry run mypy src scripts tests,poetry run bandit,poetry run radon,poetry run xenon— tous passés après correctifs.poetry run pip-audit --progress-spinner=off— no blocking vulnerabilities after bump.make cov(runs pytest + coverage) — 606 tests passed, coverage total reported at 90% andcoverage report --fail-under=90succeeded._build_npy_from_edf.Codex Task