Skip to content

Add typing_extensions.Override to SpikeDetection callback#21664

Open
mattiagaggi wants to merge 2 commits intoLightning-AI:masterfrom
mattiagaggi:fix/issue-18695-adopt-typingextensionsoverride
Open

Add typing_extensions.Override to SpikeDetection callback#21664
mattiagaggi wants to merge 2 commits intoLightning-AI:masterfrom
mattiagaggi:fix/issue-18695-adopt-typingextensionsoverride

Conversation

@mattiagaggi
Copy link
Copy Markdown

@mattiagaggi mattiagaggi commented Apr 15, 2026

Summary

Add @override decorator from typing_extensions to the SpikeDetection.on_train_batch_end method, improving type safety and making it explicit that this method overrides the parent class implementation.

Changes

  • Import override from typing_extensions
  • Add @override decorator to SpikeDetection.on_train_batch_end

Testing

  • python -m pytest tests/tests_pytorch/callbacks/test_spike.py — existing tests pass
  • mypy src/lightning/pytorch/callbacks/spike.py — type check passes

Closes #18695


📚 Documentation preview 📚: https://pytorch-lightning--21664.org.readthedocs.build/en/21664/

Add the missing @OverRide decorator to the single remaining file: src/lightning/pytorch/callbacks/spike.py. The SpikeDetection.on_train_batch_end method overrides Callback.on_train_batch_end but lacks @OverRide. Import override from typing_extensions and add the decorator. The rest of the codebase (888 uses across 120 files) was already migrated via a series of PRs (Lightning-AI#18911, Lightning-AI#18934, Lightning-AI#19065, Lightning-AI#19090, etc.). The typing_extensions version requirement (>4.5.0) already supports override.
@github-actions github-actions Bot added the pl Generic label for PyTorch Lightning package label Apr 15, 2026
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
3 pipeline(s) require an authorized user to comment /azp run to run.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79%. Comparing base (0e20e15) to head (c4acd82).
✅ All tests successful. No failed tests found.

❗ There is a different number of reports uploaded between BASE (0e20e15) and HEAD (c4acd82). Click for more details.

HEAD has 546 uploads less than BASE
Flag BASE (0e20e15) HEAD (c4acd82)
cpu 168 42
python 12 3
lightning_fabric 54 0
pytest 84 0
python3.12.7 36 9
python3.12 48 12
lightning 60 15
python3.11 24 6
python3.10 12 3
python3.13 36 9
pytorch2.1 12 6
pytest-full 84 42
pytorch_lightning 54 27
pytorch2.7 6 3
pytorch2.5.1 6 3
pytorch2.9 12 6
pytorch2.8 12 6
pytorch2.10 12 6
pytorch2.4.1 6 3
pytorch2.3 6 3
pytorch2.6 6 3
pytorch2.2.2 6 3
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #21664     +/-   ##
=========================================
- Coverage      87%      79%     -8%     
=========================================
  Files         270      267      -3     
  Lines       23973    23916     -57     
=========================================
- Hits        20748    18806   -1942     
- Misses       3225     5110   +1885     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pl Generic label for PyTorch Lightning package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt typing_extensions.Override

3 participants